Analyze rows of DataTable by class
Analyze rows of DataTable by class

I am using DataTables 1.9.4 - DataTables CDN.
In order to add columns, I destroy the table, to recreate it, loading the same DOM. To remove, hide them with display: none.
My problem is that I want to analyze all the rows in the table, for their final saved data. And for them I want to distinguish which of them are deleted (DELETE), modified (UPDATE) or created (INSERT).
My idea was to give a specific class to each "tr" to work on it, but when updating the table, the class disappears. Any solution?
Thank you
Replies
Hi Harpagornis,
Unfortunately DataTables 1.9 is no longer supported, please consider upgrading to a newer version. Also, to be able to provide some assistance please could you provide us with a test case. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Thanks,
Sandy
In addition to what Sandy said it sounds like you are using the same data but want to hide some columns and maybe make others visible. Is this correct? If so then you can use the
fnSetColumnVis
API to show/hide columns. This way you don't need to destroy nor usedisplay: none
. Just let Datatables take care of it.If the above doesn't help then, as Sandy mentioned, we would need to see a test case to understand what you are doing.
Kevin
My intention is to delete, modify or add on the DOM, without making changes to the database. At the end, click on the button to cycle through all the rows, making the changes in the database.
fnSetColumnVis allows me to hide columns, but not every record per row. True?
My intention is to update soon to 1.10, I could not show the test case, sorry.
Thanks Sandy and Kevin.
I thought you wanted to hide and show columns in the DOM based
table
.Sounds like you meant rows. If so then I would suggest using a search plugin instead of using
display: none
. Along with this add a column to yourtable
and hide it usingbVisible
. This column will contain a flag for delete, update, insert. Then use Datatables API's to add or update the rows and mark the flag column appropriately.Kevin