Deselect when selecting another row vs deselect when not selecting another row

Deselect when selecting another row vs deselect when not selecting another row

Loren MaxwellLoren Maxwell Posts: 406Questions: 99Answers: 10

Is there a way to distinguish between these two events?

I have a table with toggleable set to true. I use the selected row to filter a secondary table (which is actually done using ajax.reload() on the secondary table during the main table's select event.

If I select Row A and then Row B, it fires deselect on Row A and select on Row B, which reloads the secondary table like I would like, but when I deselect Row B for no other row it does not reload the secondary table because there was no select.

If I add the ajax.reload() on the secondary table to the deselect event on the main table then when I select Row A and then Row B, deselect fires on Row A and select fires on Row B causing the secondary table to do two ajax.reload() although only one is needed.

I can introduce a new variable outside the tables themselves to address this, but I was hoping something out-of-the-box exists.

This question has an accepted answers - jump to answer

Answers

  • Loren MaxwellLoren Maxwell Posts: 406Questions: 99Answers: 10

    I guess my shorter question would be -- does the deselect event actually know it's part of a select event?

  • allanallan Posts: 63,262Questions: 1Answers: 10,423 Site admin
    Answer ✓

    It does not - no. deselect will happen when a row is deselected, even if that is the result of another row being selected. Then select will happen.

    If I need to combine them into a single event handler, what I've done in the past is to use a debounce for them both - i.e. in deselect start a little timer. If a row is then selected, cancel the timer and process the now selected row only. If there is no row selected, the timer will complete and you can process the deselected row.

    This is what we do in SearchPanes where you might want to act on just a deselect, but more commonly you need the select event that happens after deselection.

    Allan

Sign In or Register to comment.