Mismatch in the number of fields
Mismatch in the number of fields
akshay3004
Posts: 7Questions: 0Answers: 0
I am fetching data from a PHP Backend using the fnServerData option. For some reason, while drawing the table, one more column is being expected. I get this popup: "DataTables warning (table id = 'summary'): Requested unknown parameter '13' from the data source for row 0". I just have 13 columns so parameter 13 shouldn't even be there. After investigating further, I saw that before sending the data to fnCallback there were 13 fields for every row and on returning there were 14. Any ideas regarding what I could be doing wrong?
[code]
"fnServerData": (sSource, aoData, fnCallback) ->
$.getJSON(sSource, aoData, (json) ->
for data in json.aaData
len = data.length
console.log len //output 13
fnCallback(json)
)
"fnDrawCallback": (oSettings) ->
table = that.$("#summary").dataTable()
cols = table.fnSettings().aoColumns.length
console.log cols //output 14
col = 0
while col < cols
if that.shownFields.indexOf(col) == -1
table.fnSetColumnVis(col, false)
else
table.fnSetColumnVis(col, true)
col++
[/code]
variable shownfields has been initialized with [0,1,2,3,4,5,6]
[code]
"fnServerData": (sSource, aoData, fnCallback) ->
$.getJSON(sSource, aoData, (json) ->
for data in json.aaData
len = data.length
console.log len //output 13
fnCallback(json)
)
"fnDrawCallback": (oSettings) ->
table = that.$("#summary").dataTable()
cols = table.fnSettings().aoColumns.length
console.log cols //output 14
col = 0
while col < cols
if that.shownFields.indexOf(col) == -1
table.fnSetColumnVis(col, false)
else
table.fnSetColumnVis(col, true)
col++
[/code]
variable shownfields has been initialized with [0,1,2,3,4,5,6]
This discussion has been closed.
Replies
Steph
Also see http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read .
A test case would be needed to see what is going wrong.
My guess is that there are 14 columns in the HTML. But without being able to see it, I really don;t know.
Allan