Changing aaData and redraw
Changing aaData and redraw
Hi, i use dataTable with JSON input and i'd like to refresh the table by changing the aaData and refresh the table.
So that's what i did :
[code]oTable = $(container).dataTable();
oTable.fnSettings().aaData = table.aaData; // where table.aaData contains the new aaData
oTable.fnDraw(); [/code]
The problem is that the table isn't really redrawed.. I can see in firebug that the settings has been changed in the DOM, but the table doesn't want to change...
Can you help me please ?
PS :
Have you got a function to check that a selector is or not a dataTable ? so because i'm using it with json i checked if it was empty like that
[code]if($('tr', container).length != 0)[/code] but is there a better way ?
Thank you very much
So that's what i did :
[code]oTable = $(container).dataTable();
oTable.fnSettings().aaData = table.aaData; // where table.aaData contains the new aaData
oTable.fnDraw(); [/code]
The problem is that the table isn't really redrawed.. I can see in firebug that the settings has been changed in the DOM, but the table doesn't want to change...
Can you help me please ?
PS :
Have you got a function to check that a selector is or not a dataTable ? so because i'm using it with json i checked if it was empty like that
[code]if($('tr', container).length != 0)[/code] but is there a better way ?
Thank you very much
This discussion has been closed.
Replies
There is no "fnSettings().aaData" parameter - so this wouldn't work. What you would need to do is use fnClearTable() followed by fnAddData() - http://datatables.net/api - which would give you this effect and uses the public API methods.
Allan
An instance this would be useful is when reading a database and not wanting to display all data types, but allowing the user to pick and add more data columns.
Ideally, would be nice to do this without having to reinstantiate the table and reapply all settings.
Allan