about the parameters in post data of version 1.10

about the parameters in post data of version 1.10

marsmars Posts: 29Questions: 2Answers: 0

hi, Allan and all

i found Datatables have released a new version 1.10, and i found that the parameters in post data have changed.

in old versions:
parameters of post data may be: sEcho, sColumns, iTotalRecorders, iColumns, and so on..
in new version of 1.10.x, i found only find the paras below:
draw, start, length, order[i][column]...

is there a clear way to find the column numbers from the paras?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Answer ✓

    Regarding the change, you can switch back to the old style if needed - see the manual.

    is there a clear way to find the column numbers from the paras?

    I don't quite understand - do you mean the number of columns? In which case just use count( columns ) (in PHP - I'm sure other languages can do similar).

    Allan

  • marsmars Posts: 29Questions: 2Answers: 0

    hi, allan

    i watch the post data from JS in my IDE and it looks like below:
    {draw=[1], columns[0][data]=[col1], columns[0][name]=[column1], columns[0][searchable]=[true], columns[0][orderable]=[true], columns[0][search][value]=[], columns[0][search][regex]=[false], columns[1][data]=[col2], columns[1][name]=[column2], columns[1][searchable]=[true], columns[1][orderable]=[true], columns[1][search][value]=[], columns[1][search][regex]=[false], columns[2][data]=[col3], columns[2][name]=[column3], columns[2][searchable]=[true], columns[2][orderable]=[true], columns[2][search][value]=[], columns[2][search][regex]=[false], order[0][column]=[0], order[0][dir]=[asc], start=[0], length=[10], search[value]=[], search[regex]=[false], myKey=[myValue]}

    and here comes my datatable's setting code:
    ...
    "serverSide" : true,
    "processing" : true,
    "columnDefs" : [
    { "visible": true, "targets": [ 0 ], "title":"Col1", "data":"col1", "name":"column1" },
    { "visible": true, "targets": [ 1 ], "title":"Col2", "data":"col2", "name":"column2" },
    { "visible": true, "targets": [ 2 ], "title":"Col3", "data":"col3", "name":"column3" },
    ],
    "ajax" : {
    "url" : "/test/analyzeDatatablePara/",
    "type" : "POST",
    "dataType" : "json",
    "data": function(data) {
    return $.extend({}, data, {"myKey":"myValue"});
    }
    }
    ....

    it means i can not get the 'columns' from the request, but use 'columns[0][data]' as parameter name

  • marsmars Posts: 29Questions: 2Answers: 0

    sorry,
    i find the answer, i should dump the para to json and send it to server.
    like:
    "ajax" : {
    ...
    "data": function(data) {
    var para = {
    "aoData" : JSON.stringify(data),
    "myKey" : "myValue"
    };
    return para;
    }
    ...

This discussion has been closed.