row.child.isShown falsely reporting True

row.child.isShown falsely reporting True

jonfrankjonfrank Posts: 3Questions: 1Answers: 0

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

  1. click on 'see details' in either row to open the details table
  2. 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)
  3. click 'back to all contracts' under the table to return to the overview
  4. 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

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    edited July 2018 Answer ✓

    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:

    1. Only add the events the first time the details table is created.
    2. Remove the events on the details table whenever you click the back to all button allowing them to then be added again.

    Allan

  • jonfrankjonfrank Posts: 3Questions: 1Answers: 0

    Many thanks Allan. I get it... will rework it appropriately.

  • jonfrankjonfrank Posts: 3Questions: 1Answers: 0

    Magic - all working now. Many thanks for such a swift resolution

This discussion has been closed.