multi-row footer data

multi-row footer data

datahandlerdatahandler Posts: 26Questions: 2Answers: 1

According to the documentation, if we have multiple rows in a footer, we have to use the table().footer() method and manipulate the additional footer rows using standard jQuery or DOM methods.

In my case, I have hidden columns and I need to update the data for hidden footer cells in the second footer row. Now, when I un-hide columns, the original footer values are restored for the second row, so I know datatables is storing them somewhere. My question is, where does datatables store the additional footer row data and can I access it to update it?

Thanks

Replies

  • colincolin Posts: 15,236Questions: 1Answers: 2,598

    Hi @datahandler ,

    DataTables currently only caches the top footer row, so only that can be accessed and updated while the column is invisible through the API. If you have additional rows, you'll need to update those when the column becomes visible again.

    You can either do that after the column().visible() call, or you can do inside column-visibility,

    Cheers,

    Colin

  • datahandlerdatahandler Posts: 26Questions: 2Answers: 1
    edited August 2018

    Thanks Colin. I clearly don't understand something :-(

    If datatables only caches the first footer row, how is it displaying my original footer values for the second row when I un-hide a hidden column?

  • allanallan Posts: 62,994Questions: 1Answers: 10,368 Site admin
    edited August 2018

    Its not that it doesn't cache the cells from the other rows, its rather than they aren't visible via the API. Two different mechanisms are currently used for this - there is a nTfparameter that DataTables stores internally in its aoColumns array (which you can see using settings() - although keep in mind that the settings are considered to be private and might change!). When you use column().footer() it is that parameter which is returned.

    The column visibility however uses a mapping array that is constructed when the table is created. This is where it is used for the column visibility.

    You could use table.settings()[0].aoFooter and parse through the objects in the 2D array there, but that can and will change.

    In fact I've recently been doing some work in this area for v2 - the nTf parameter is now gone and the API does indeed present a method to get cells from all rows in the footer, regardless of colspan or rowspan.

    I guess the obvious question having said that is "when will v2 with this feature be available". I don't know yet! There is still a ton of other stuff that is on the list to be done :).

    Allan

  • datahandlerdatahandler Posts: 26Questions: 2Answers: 1

    Thank you, Allan. Good to know this is coming. Look forward to it!

This discussion has been closed.