multi-row footer data
multi-row footer data
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
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 insidecolumn-visibility
,Cheers,
Colin
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?
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
nTf
parameter that DataTables stores internally in itsaoColumns
array (which you can see usingsettings()
- although keep in mind that the settings are considered to be private and might change!). When you usecolumn().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
Thank you, Allan. Good to know this is coming. Look forward to it!