Dynamically change priority of responsive extension
Dynamically change priority of responsive extension

I want to navigate to columns on button click that are hidden by the responsive extension. Therefore I change the priority of the header columns via the data-priority attribute. The priority will be set accordingly and the responsive extension will be rebuild and recalced. But only the first click works. Later changes will not happen.
Here is a demo link:
1. Resize the window that only one column is visible
2. click on "nächste Spalte" -> works
3. click on "nächste Spalte" again -> does not work
Any idea what is going wrong? Is there another way to achieve my goal?
This question has accepted answers - jump to:
Answers
Hi @DataTableFan ,
Your logic is a little wonky - see here. You're looking from the end for the first visible column, but only doing stuff if
lastVisibleIndex > 0
. On the second iteration it is0
, since those last columns are now visible. If you add debug in as I did, you can follow the path. I'm not clear how this would work, it seems to be creating a confusing interface, so I can't really comment on the best way forward I'm afraid.Cheers,
Colin
Hi @colin ,
I have updated the example (demo link). Maybe you have a larger screen. So I have limited the width of the table. Now you can see that the first click works fine but a further one not. In the console logs are the current priority order of the header columns that are correct but are not applied by the responsive extension after the first update.
Thanks for the demo. Its because of these lines. I never expected the responsive priority to be changed after initialisation (via the data attributes or any other way), so it isn't looking for that.
It works the first time since it is still using the default priority, so that
if
condition passes and it gets the data attributes.The solution would be to check the
if
condition to check if there is adata-priority
attribute, and if so, use that regardless of the undefined check.I'll talk to Colin about if we want to include that.
Allan
Hi @DataTableFan ,
I just made that change to the plugin. It will be available in the next release, or now, in the nightly builds - see here.
Hope that does the trick,
Cheers,
Colin
Hi,
thank you very much. Now it works