Getting warning 4 when supplying DT_RowId

Getting warning 4 when supplying DT_RowId

msemeonmsemeon Posts: 2Questions: 1Answers: 0

using datatables .10 and query 2.1.3
This is the table config:
$('#reportsTable').DataTable({
"processing" : true,
"serverSide" : true,
"ajax" : {
"url" : "/reportManager/getData",
"type" : "POST"
},
"columns":[
{'data':'name'},
{'data':'date'},
null
]
});

And this is the response from the server
{"draw":1,"recordsTotal":1,"recordsFiltered":1,"data":[{"DT_RowId":"2","name":"a test report","date":"15 Feb 2015"}]}

the table shows the correct values - 2 first columns populated and tr has the 2 set properly but I get the Warninf 4 - what am I doing wrong?

This question has accepted answers - jump to:

Answers

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

    Why is there a null in your columns? "columns":[ {'data':'name'}, {'data':'date'}, null ] }
    Try making it: "columns":[ {'data':'name'}, {'data':'date'} ] }

  • msemeonmsemeon Posts: 2Questions: 1Answers: 0

    I have 3 columns in my table - still waiting to find out what goes in the third column - thought I needed to match the columns array size with the number of columns. But removing the null made it work - thanks.

  • ignignoktignignokt Posts: 146Questions: 4Answers: 39
    edited February 2015 Answer ✓

    You can pass back any amount of data and only use one if you wish. If you did want to leave a column empty for now you could do it this way though I believe:

    "columns":[ {'data':'name'}, {'data':'date'}, {'data':null, 'sDefaultContent':''} ] }

This discussion has been closed.