Multiple row unselect using shift

Hey everyone. I'm using the SfDataGrid with selectionMode: SelectionMode.multiple, and the multi-selection works great. However, I noticed that the unselect event is restricted to one row only, and there's no way to unselect multiple rows while pressing shift (like the behavior implemented on GMail, for example).


Is there a way to enable this kind of behavior without having to rewrite the selection manager?


1 Reply

AP Abinesh Palanisamy Syncfusion Team May 16, 2024 06:33 AM UTC

Hi Filipe Moreira,


In SfDataGrid, you can select and deselect multiple rows using the Shift key. To do this, first select a row normally, without pressing any key; this is considered the pressedRowIndex. Then, while holding down the Shift key, select another row, which is considered the currentRowIndex. This action will select all the rows between the pressedRowIndex and the currentRowIndex.


To deselect multiple rows using the Shift key, the pressedRowIndex remains the same, but you change the currentRowIndex to deselect the rows. This process will remove the selection from the rows that are no longer between the pressedRowIndex and the new currentRowIndex.


Additionally, it is important to note that selection and deselection with the Shift key should happen simultaneously. If you perform a normal selection after selecting rows with the Shift key, both the pressedRowIndex and currentRowIndex will be reset. Similarly, if any rows were selected normally before performing a Shift selection, they will not be included in the Shift key selected rows.


If you have any further misunderstandings regarding your requirements, or if your needs differ in any way,  provide clear details about your use case. This additional information will enable us to thoroughly address your request and provide an appropriate solution.


Regards,

Abinesh P


Loader.
Up arrow icon