How to deselect() all rows BUT passing data to de event

How to deselect() all rows BUT passing data to de event

barlebybarleby Posts: 10Questions: 3Answers: 0

From File a.js I'm deselecting all rows in my Table with: table.rows().deselect();
In file b.js I have a listener:

table.on("select.dt deselect.dt", function (e, dt, type, indexes) { /* my code */ })

For the logic of my app, I need to pass some data along when calling deselect(). But deselect(), doesn't take in any parameter.
I tried to 'simulate' the deselect.dt event via:

table.trigger('deselect.dt', {dataToBePassed});

But the _on() _listener callback won't be called.
Any Idea on how I could deselect all row while passing data to the event?

Thanks!!!

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,261Questions: 26Answers: 4,934

    Please provide more details of what you are trying to do. Where the data is coming from that you want to pass into the event and what you want to do with it? Maybe we can offer some suggestions.

    Kevin

  • barlebybarleby Posts: 10Questions: 3Answers: 0
    edited March 2022

    Hi. The reason of doing this is the following:

    There is Table A and Table B in the screen.
    I need that when I Select/check any row in Table A, All Table-B rows get deselected (if any).
    Both A and B display a side View in the screen offering info to the user when clicking, regarding to the clicked Row (that's the reason why only checks in 1 table at a time are allowed).

    Problem is: Each table has an event listener when user select/deselect rows. When 0 rows are selected in the table, a side View with a message of "no rows selected from this table" is rendered.

    When my .js detetcs user has checked 1 row in Table A, automatically Table A in fact renders a View with Data related to the clicked row

    What happens next is my .js attemps to deselect() any other rows in any other table in the Screen (in this case table B). This causes that table B renders its own empty side View, overriding the formerly rendered by Table A.
    That's why I need to pass some kind of Flag (data) to indicate Table B event handler y its rows are deselected from an "outside" table or not, to perform different actions according this.

  • barlebybarleby Posts: 10Questions: 3Answers: 0

    I have multiple Tables at a time in the screen. Whenever I click a row in one, all other rows in the remaining tables must be deselected.
    The reason is that each Table renders a View with info regarding that particular table.

    When I select/unselect rows in the same Table, the table performs some logic regarding the Side View.
    Problems appears when a Table has its rows deselected from an external Table, because I need to perform a different logic.

    So, I would need to pass some flag/data with deselect() to inform the affected table if its rows have been deselected from "outside"(another table) or not.

  • kthorngrenkthorngren Posts: 21,261Questions: 26Answers: 4,934
    Answer ✓

    Maybe you can call a function with the dataToBePassed that calls rows().deselect() for table B and usesdataToBePassed information to update the side view for table B.

    Kevin

  • barlebybarleby Posts: 10Questions: 3Answers: 0

    I was thinking of a similar solution, though it didn't seem to me very 'elegant'
    As a suggestion, allowing deselect() to take-in arguments that could be retrieved in the event listener function (e.data) would be great.
    Thanks a lot

Sign In or Register to comment.