columnDefs php generated

columnDefs php generated

ltdetaltdeta Posts: 23Questions: 9Answers: 0
edited January 2015 in Free community support

How should I create this javascript columndefs - data with php?

"columnDefs": [
{ "targets": [0,1], "searchable": false, "title": "column1"},
{ "targets": [2], "searchable": true, "title": "column2"}
]

the result should be

"columnDefs": data.ColumnDef     //data.ColumnDef is generated outside the datatabletable object

This question has an accepted answers - jump to answer

Answers

  • ignignoktignignokt Posts: 146Questions: 4Answers: 39
    Answer ✓

    I think you can do this with an ajax call before datatables are initiated, just not with the same call that loads the server-side data if you are using that. Below is a correctly formatted PHP array for your columnDefs example.

    $columns = 
    array(
        0=>array(
           "targets"=>array(0,1),
           "searchable"=>false,
           "title"=>"column1"
        ),
        1=>array(
            "targets"=>array(0,1),
            "searchable"=>false,
            "title"=>"column1"
        )
    );
    echo json_encode($columns);
    
This discussion has been closed.