CellRangeEventArgs not providing actual select/deselect value

Posted by: teun.kokke on 28 March 2024, 1:34 am EST

  • Posted 28 March 2024, 1:34 am EST

    https://developer.mescius.com/wijmo/api/classes/Wijmo_Grid.Flexgrid.html#onwbrselectionwbrchanged

    I have row selection checkboxes, and am listening to the selectionChanged event. However FlexGrid emits this event twice when clicking a checkbox for some reason (why is this?). So I want to ignore the second emission when the event payload contains the same row value for the selection.

    However it is not clear to me how to distinguish this from toggling the selection ON/OFF. Both cases hold the same row value, and I can’t find anything in the docs suggesting whether that selection event was turning that selection ON or OFF.

    https://developer.mescius.com/wijmo/api/classes/Wijmo_Grid.Cellrangeeventargs.html

    Am I missing something?

  • Posted 31 March 2024, 9:26 pm EST

    Hi Teun,

    This is the expected behavior that the selectionChanged event is triggered two times when selector checkboxes are used in the cells panel instead of the rowHeaders panel. The reason behind this behavior is that when you click on the checkbox, the whole row is selected due to which the selectionChanged event is triggered, and at the same time the cell that contains the checkbox becomes the active cell, triggering the selectionChanged event a second time.

    To avoid this situation, you can use the column in rowHeaders panel of the grid, to show the selector checkboxes, you can also insert more columns in the row headers panel if needed, by referring to the following sample - https://developer.mescius.com/wijmo/demos/Grid/Columns/Collections/angular.

    And if you are using the selectionChanged event, just to get the information about the rows selected using the checkboxes, then you can handle the ‘itemChecked’ event of FlexGrid Selector for this purpose, instead of the ‘selectionChanged’ event, and get the selected rows like this -

    grid.rows.filter((r) => r.isSelected)

    To get the exact information about the checked/unchecked state of the selector checkboxes, you can handle the ‘click’ event on the flexGrid’s host element, and use the hitTest method to evaluate the click information and get the right information about row selection. Please refer to the following sample demonstrating the same - https://stackblitz.com/edit/angular-ivy-p4zhdw?file=src%2Fapp%2Fapp.component.ts

    In case, you face any issues, please let us know.

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels