Bug found in ajax mode
Bug found in ajax mode
matthieucan
Posts: 5Questions: 0Answers: 0
Hi,
I'm using Datatables 1.9.
When I do this:
[code]
$(document).ready(function() {
$('#res').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/rest/status/json/custom_view/?viewname=foo"
} );
} );
[/code]
I get the error Uncaught TypeError: Cannot read property 'asSorting' of undefined.
However, with
[code]
$(document).ready(function() {
$('#res').dataTable( {
"aaData": [
[
"google.com",
"HTTP",
]
],
"aoColumns": [
{
"sTitle": "host_name"
},
{
"sTitle": "description"
}
]
} );
} );
[/code]
It works like a charm. Obviously, the same content is delivered through "/rest/status/json/custom_view/?viewname=foo".
Any pointer? Is that a bug?
Thanks.
I'm using Datatables 1.9.
When I do this:
[code]
$(document).ready(function() {
$('#res').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/rest/status/json/custom_view/?viewname=foo"
} );
} );
[/code]
I get the error Uncaught TypeError: Cannot read property 'asSorting' of undefined.
However, with
[code]
$(document).ready(function() {
$('#res').dataTable( {
"aaData": [
[
"google.com",
"HTTP",
]
],
"aoColumns": [
{
"sTitle": "host_name"
},
{
"sTitle": "description"
}
]
} );
} );
[/code]
It works like a charm. Obviously, the same content is delivered through "/rest/status/json/custom_view/?viewname=foo".
Any pointer? Is that a bug?
Thanks.
This discussion has been closed.
Replies
So not a bug here I think.
Allan
I don't have columns defined in my html for a simple reason: I don't know the number of columns in advance. And it *works* in the 2nd case, without defining columns either.
Thoughts?
If you don't know the columns in advance you need to make the Ajax request yourself and then populate either the HTML or aoColumns with the information about the columns. DataTables itself currently does not dynamically create columns.
Allan
The fact here is: for exactly the same content (in one case embedded in code, in the other case delivered by ajax), one program works like a charm and the other one doesn't.
Yes, but DataTables doesn't use the aoColumns object in the return. There is nothing in the documentation to indicate that it will.
I fully accept that it should, and it will in future versions, but it doesn't at the moment.
Allan
Allan