I don't understand how to write a plugin for this library.

I don't understand how to write a plugin for this library.

MoghulMoghul Posts: 7Questions: 3Answers: 0

I'm looking at the documentation here https://datatables.net/manual/plug-ins/features#new-initialisation and I can see how to initialize a plugin, and I can figure out by looking at the api how to retrieve the data which interests me, but I can not figure out how to change this data to match my needs.

I am trying to make a plugin which will modify both the header and the cells of a column - specifically by merging columns into each-other.
I have other plans for making plugins as well such as dropdowns in the header for filtering.

Can anyone provide me with just a little snippet of code modifying the header and the cells, just adding some random string to them?

PS: I know renderers exist for cells, but that's not quite enough for my purposes. I don't have anything against using them as part of the final solution, but it's insufficient for my purposes.

Answers

  • MoghulMoghul Posts: 7Questions: 3Answers: 0

    Looks like you can change values of aoColumns and aoData and they'll stick.

  • allanallan Posts: 50,248Questions: 1Answers: 7,465 Site admin

    aoColumns and aoData

    Bad idea :). I consider the settings object to be internal to DataTables. It can, will and does change (albeit occasionally) between versions.

    The API is the best way to interact with the table - e.g. cell().data() to get / set the data for a cell.

    Regards,
    Allan

Sign In or Register to comment.