How can I update data-filter attribute?
How can I update data-filter attribute?
Dimetrius
Posts: 7Questions: 2Answers: 0
How can I update data-filter attribute for specific cell?
My cell has id, I update data-filter like
document.getElementById('cell-56').setAttribute('data-filter','new value');
After setAttribute DataTable filter not use 'new value'.
How can I update data-filter attribute to take effect?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You need to call
row().invalidate()
after you update the element to tell DataTables that it needs to reread from it.Allan
I try add data-filter attribute in createdRow
This add new attribute, but filter still can't find "new value"
My html table cell looks like
After I do
Filter can find row by "two value", but "one value" ignored.
Maybe it is bug?
If you link to a page showing the issue I would be happy to take a look and try to debug it.
Allan
Hmmm actually:
So it didn't have that attribute before? If so, DataTables won't automatically detect it having been added.
Perhaps you could explain a bit about what it is you are looking to do overall.
Allan
I made fiddle with simple table and three rows
JSFiddle
I want add a fourth row.
New fourth row must be sortable and filter like first three.
How to add new fourth row in my case?
To add a new row, rather than updating an existing one as we discussed above, you can create the
tr
element yourself and pass it in: https://jsfiddle.net/804dg124/1/ .The alternative is that you pass in an object that contains the same data structure that DataTables creates from the row and attributes:
Allan
This works, Allan, thank you very match!