3

Can DataTables read columns (names) list from its ajaxSource?

I mean that I define columns in my PHP file and pass them with data, then dataTables parses them and create the table (full dynamically)

Thanks.

1
  • 1
    Yes, it is possible. Here's a link! Commented Sep 12, 2012 at 7:07

1 Answer 1

0

if your ajaxSource is something like :

           { 
            "aaData": [
             {
              a:"Trident",
              b:"Internet Explorer 4.0",
              c:"Win 95+",
              d:4,
              e:"X"
             } // [...]
           ],
           "aoColumns": [
            {
                "mData": "d",
                "sDefaultContent": 0
            },
            {
                "mData": "a",
                "sDefaultContent": "-"
            } //[...]
            ]}

you can do this call :

         $.getJSON('ajaxSource.php',function(json) {
                  json.bDestroy = true;
                  $('#example').dataTable(json);
         });
Sign up to request clarification or add additional context in comments.

Comments

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.