0

i tried but unable find every time some sort of error comes,please help me out, the json Data:

{ "siteList": [ 
    { "siteName": "Site1", 
        "deviceList": [ 
            { "deviceName": "S1device1", "count": "1" }, 
            { "deviceName": "S1device2", "count": "2" } 
            ] 
    }, 
    { "siteName": "Site2", 
        "deviceList": [ 
            { "deviceName": "S2device1", "count": "1" }, 
            { "deviceName": "S2device2", "count": "2" } 
            ] 
    }, 
    { "siteName": "Site3", 
        "deviceList": [ 
            { "deviceName": "S3device1", "count": "1" }, 
            { "deviceName": "S3device2", "count": "2" } 
            ] 
    } 
    ] 
}

I want to show it on the html table using Datatable Here is the html:

<table id="example" class="display" style="width:100%">
        <thead>
            <tr>
                <th>Site Name</th>
                <th>Cabinet</th>
                <th>Count</th>
               
            </tr>
        </thead>
    </table>

And the Jquery:

 $(document).ready(function() {
         $('#example').DataTable( {
            "ajax": "user.json",
            "columns": [
                { "siteList": "siteName" },
                { "siteList": "deviceList:deviceName" },
                { "siteList": "deviceList:count" },
               
            ]
        } );
    } );

Please help me to do it any help would be highly appreciated Thanks in advance

1 Answer 1

1

user.json should looks diferent..

take a look here: https://datatables.net/examples/ajax/simple.html

Sign up to request clarification or add additional context in comments.

1 Comment

wait You need to create nested in table table ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.