$(...).remove(...).draw is not a function.Why it's not working?
$(...).remove(...).draw is not a function.Why it's not working?
MS_26
Posts: 1Questions: 1Answers: 0
"fnRowCallback" : function(nRow,aData, iDisplayIndex,iDisplayIndexFull) {
$.each(aData,function(k, v) {
if (k == "ACCOUNT_NUMBER") {
if (v == mirror_account_number) {
```$(nRow).remove().draw();```
}
}
})
},
This discussion has been closed.
Answers
I used the newer syntax. Try this please:
If that doesn't work you might need to do the draw() later outside the callback.
Is your goal to filter certain rows based on content?
rowCallback
is not the place to remove rows. The reason it doesn't work is$(nRow).remove()
is a jQuery method and.draw()
is a Datatables API. Datatables won't know about changes to the table you make using$(nRow).remove()
and would result in a confusing table display.My suggestion is to create a Search Plugin that filters the rows you don't want to display.
Kevin
I guess Kevin is right! So ignore my previous post please.
You can actually use the search functionality Kevin mentioned without creating a plugin. You just add this code on top of your Data Table definition
If you have muliple Data Tables on your page this code will run for each table. Hence you need to check for "undefined" in order to avoid problems with other tables.
That is a search plugin Thanks for providing an example(I was being lazy).
Kevin
I always think of a separate file and an installation process when I hear plugin
Thanks for clarifying!
Roland
The term plugin does make it seem more than it really is. It is a very cool feature of Datatables.
Kevin