Hide/show specific FixedHeader on action with multiple tables on same page
Hide/show specific FixedHeader on action with multiple tables on same page
rmayer
Posts: 5Questions: 1Answers: 0
Hello,
Firstly, I can't link to a page, as the implementation is within an intranet environment, so please bear with me.
I have two DataTables on a page, both with the FixedHeader plugin invoked. Since one of the tables is changed using $.ajax to other content (not using DataTables), on a user action, I wish to be able to hide and re-show this SPECIFIC FixedHeader object at the same time. The other table (also using DataTabes/FixedHeader) should remain in place at all times.
Currently, when the said DataTables table is replaced with the new content, the FixedHeader lingers, since this object has not been hidden. If I hide it using $('.fixedHeader').hide() then obviously BOTH FixedHeader table headers are hidden, being the same class. I can't see a way of specifying the id/class of a FixedHeader and hence address it individually.
Furthermore, $('.fixedHeader').show() does not behave as expected even if you submit to the idea that both FixedHeaders will turn on/off together, since this FixedHeader reappears in the top left of the screen and not in its original position.
Any help/guidance on this issue would be appreciated. I hope I have provided enough information, but if not, do let me know and I'll go into more detail.
Many thanks.
Richard
Firstly, I can't link to a page, as the implementation is within an intranet environment, so please bear with me.
I have two DataTables on a page, both with the FixedHeader plugin invoked. Since one of the tables is changed using $.ajax to other content (not using DataTables), on a user action, I wish to be able to hide and re-show this SPECIFIC FixedHeader object at the same time. The other table (also using DataTabes/FixedHeader) should remain in place at all times.
Currently, when the said DataTables table is replaced with the new content, the FixedHeader lingers, since this object has not been hidden. If I hide it using $('.fixedHeader').hide() then obviously BOTH FixedHeader table headers are hidden, being the same class. I can't see a way of specifying the id/class of a FixedHeader and hence address it individually.
Furthermore, $('.fixedHeader').show() does not behave as expected even if you submit to the idea that both FixedHeaders will turn on/off together, since this FixedHeader reappears in the top left of the screen and not in its original position.
Any help/guidance on this issue would be appreciated. I hope I have provided enough information, but if not, do let me know and I'll go into more detail.
Many thanks.
Richard
This discussion has been closed.
Replies
+1 for this feature request (thanks rmayer)
i have several dataTables in separate collapsable divs, i want to remove the related FixedHeader when a specific table is collapsed (otherwise the fixed header will stay put on its current position).
+1!! It is really awful if we don't have ability to work with extension on single page applications! If datatable's instance removed (removed table from DOM), even without datatable API's method destroy(), or datatable is hidden on the page (has display: none; !$table.isVisible()), FixedHeader should be removed as well! And re-created on table appears again).
For now I didn't find better solution than running this function every 1 sec (but it's terrible!!!):
Please fix it ASAP!
This feature exists in the development version of FixedHeader. I would welcome anyone trying it out and letting me know how you get on with it.
Allan
Dear allan, if I want to use it, I have to use callback of datatables onTableHidden(), which is not implemented in the API. So this feature could work only if I have some other functionality to catch table's visibility - which is related to other page elements, not to datatable. It's a violation of patterns.
Feature also don't cover the case if user goes to another page using AngularJS. When user returns back, new FixedHeader_Cloned element will be created, we can't use hidden FH again, because datatable destroyed (removed from DOM) and created again.
If you set an element to
display:none
, there is no event triggered (at least that I am aware of - would love to be proven wrong there as it would be exceptionally useful!) so I can't know that this has happened.For complete separation of components your best bet would be to trigger a custom event that would signal that an element has been hidden and have an event handler that would perform whatever updates are needed.
Allan