Analyze rows of DataTable by class

Analyze rows of DataTable by class

HarpagornisHarpagornis Posts: 8Questions: 1Answers: 0

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

  • sandysandy Posts: 913Questions: 0Answers: 236

    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

  • kthorngrenkthorngren Posts: 21,154Questions: 26Answers: 4,919

    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 use display: 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

  • HarpagornisHarpagornis Posts: 8Questions: 1Answers: 0

    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.

  • kthorngrenkthorngren Posts: 21,154Questions: 26Answers: 4,919
    edited August 2019

    In order to add columns, I destroy the table, to recreate it, loading the same DOM. To remove, hide them with display: none.

    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 your table and hide it using bVisible. 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

This discussion has been closed.