0

How to bind dynamic JSON object to jquery data table. Did anyone worked on such scenario.

For example,

var objTable = jQuery.parseJSON(result);

        if objTable != null && objTable .length > 0) {
            $('#tblName').dataTable({
                "bDestroy": true,
                "bScrollCollapse": true,
                "bJQueryUI": true,
                "bPaginate": false,
                "sScrollY": "310px",
                "bInfo": true,
                "bFilter": true,
                "bSort": true,
                "aaData": objTable,
                "aoColumns": [
                    { "mData": "Field1" },
                    { "mData": "Field2" },
                    { "mData": "Field3" },
        .
        .
        .
        .
                    { "mData": "FieldN" }]    //These are dynamically created columns present in JSON object.

            });
        }

1 Answer 1

1

Its possible to add the data to datatable dynammically

Like this

$('#YourTableID').dataTable().fnAddData([sno,msg.json[i].unit_id,msg.jsoni].date_time,msg.json[i].sms_number,msg.json[i].message]);

Befor that you have 5 headers in table for appending above

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

1 Comment

could you please describe what are sno, msg.json in the above code

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.