redraw all tables?
redraw all tables?
mambomonkey
Posts: 10Questions: 0Answers: 0
hey there!
I seem to be having a problem targeting some of the datatables, i have a system which creates datatables dynamically so there are multiple tables on on the page.
each table has an id of '#t0', '#t1', '#t2', '#t3' etc...
and all have the same class 'dtable'
im trying to do something like this
$('.dtable').dataTable().fnDraw()
so that all the datatables with this class will redraw, im also trying to do it with the ajax refresh plugin.
But this doesnt work, has anyone got any ideas how I would go about this?
is there there a 'redraw all' function I can use? ( i hope there is ;) )
thanks for your help in advance ;)
I seem to be having a problem targeting some of the datatables, i have a system which creates datatables dynamically so there are multiple tables on on the page.
each table has an id of '#t0', '#t1', '#t2', '#t3' etc...
and all have the same class 'dtable'
im trying to do something like this
$('.dtable').dataTable().fnDraw()
so that all the datatables with this class will redraw, im also trying to do it with the ajax refresh plugin.
But this doesnt work, has anyone got any ideas how I would go about this?
is there there a 'redraw all' function I can use? ( i hope there is ;) )
thanks for your help in advance ;)
This discussion has been closed.
Replies
While not identical to what you are looking for, it's very close, the fnFilterAll ( http://datatables.net/plug-ins/api#fnFilterAll ) plug-in will show you how this can be done (it uses fnFilter rather than fnDraw or anything else).
If you do create an API function for this, perhaps you can post your code so I can put it up on the plug-ins page for others?
Allan
ahh right ok, fair enough!
I tried what you said looking at the fnfilterAll and tried to implement the $.fn.dataTableExt.iApiIndex parameter, but I couldnt quite get it to work (bit of a jquery rookie).
I have now changed my code so i dont use the oTable variable but call to a specific table id,
e.g. -> '$('#t3).dataTable().fnReloadAjax();'
which works sometimes but is not completely stable, if I go back a table (i have tables on a slide) and try to run the
.fnReloadAjax() function i get:
Result of expression 'oSettings' [null] is not an object.
any ideas?
is this because of the way I am calling the reload ajax function? not using the oTable?
thanks for the help :)
Allan
iApiIndex is always 0, just to double check, I need the iapindex to go up for each table right?
so..
$('#t0).dataTable() has iapindex of 0
$('#t1).dataTable() has iapindex of 1
$('#t2).dataTable() has iapindex of 2
and so on
that way it knows to target say..#t1? (if i set the index to 1?)
so how do I set the target iapindex?
$.fn.dataTableExt.iApiIndex = 1 ?
thanks again for the help, im sure theres away around this :)