row.child.isShown falsely reporting True
row.child.isShown falsely reporting True
I've got a strange problem with a details disclosure button on a table row.
Two tables, one with overview data and on each row the user can click to see a table of details for that row. Each table is in a separate <div>
which is hidden / shown as needed.
First time I go into the details table, and then click on a + in the first column to expand the child data for that row (details within details!) it works fine. I then return to the overview data, and then back into the details table. The + disclosure button doesn't work. (Debug shows that it's because child.isShown()
is incorrectly returning true.)
Strangely though, when I go back to overview and then back into details for a third time, it works again. And it continues to toggle: working, broken, working, broken.
I've rigged up a demo of the problem at https://gigachain.net/datatables-test.html
- click on 'see details' in either row to open the details table
- click on the green + in column 0 to show the child rows (note that the blue box at the top gives the relevant debug message)
- click 'back to all contracts' under the table to return to the overview
- repeat and see it work and fail alternately
Even with my real data, it doesn't seem to matter which rows you try, whether you're going back to the same details table or a different set of data. I destroy the details table each time to allow me to recreate it with new data.
The issue is on line 161 of datatables-test.js
many thanks
Jonathan
This question has an accepted answers - jump to answer
Answers
Hi Jonathan,
What is happening here is a build up of events. Every time you view the details table, another set of events are added to it, and then clicking on the show/hide button triggers all that have been added. So on the third view, it is triggering the
isShown
check three times!One of my old debug tools, Visual event, is useful for this sort of thing. You can see the build up of events.
There are two options:
back to all
button allowing them to then be added again.Allan
Many thanks Allan. I get it... will rework it appropriately.
Magic - all working now. Many thanks for such a swift resolution