Added data does not match columns
Added data does not match columns
kellyjandrews
Posts: 15Questions: 0Answers: 0
Working on a setup using an ajax post to return data to the datatable function.
The data that is returned, when put directly into the datatable works as expected, but when put into the $.put call, it's not working.
See example as follows:
[code]
$(document).ready(function() {
$.post("aspx page to return data",
function(data){
$('#grid1').dataTable( {
"bProcessing": true,
"aaData": data,
"bAutoWidth" : false,
"asStripClasses" :['Row', 'RowAlternate'],
"aoColumns": [
{ "bSortable": false },
null,
null,
null
]
}).wrap('');
});
});
[/code]
And the data that is returned looks like this:
[code]
[
['','PageName','10000','10/18/2009 7:39:38 PM'] ,
['','PageName','10000','10/18/2009 7:39:38 PM'] ,
['','PageName','10000','10/18/2009 7:39:38 PM']
]
[/code]
Again - when data is placed directly in the "aaData" array, it is working.
The following is the page code it goes into - showing the 4 column headers:
[code]
Name
ID
Created
[/code]
The data that is returned, when put directly into the datatable works as expected, but when put into the $.put call, it's not working.
See example as follows:
[code]
$(document).ready(function() {
$.post("aspx page to return data",
function(data){
$('#grid1').dataTable( {
"bProcessing": true,
"aaData": data,
"bAutoWidth" : false,
"asStripClasses" :['Row', 'RowAlternate'],
"aoColumns": [
{ "bSortable": false },
null,
null,
null
]
}).wrap('');
});
});
[/code]
And the data that is returned looks like this:
[code]
[
['','PageName','10000','10/18/2009 7:39:38 PM'] ,
['','PageName','10000','10/18/2009 7:39:38 PM'] ,
['','PageName','10000','10/18/2009 7:39:38 PM']
]
[/code]
Again - when data is placed directly in the "aaData" array, it is working.
The following is the page code it goes into - showing the 4 column headers:
[code]
Name
ID
Created
[/code]
This discussion has been closed.
Replies
I presume you are using fnAddData somewhere? Could you possible include that code - or ideally a link showing the problem?
Thanks,
Allan