get selected cells in grid

I am trying to get user's selected cells. In single cell selection mode, I can use cellSelected event to get the index of the cell.

In multiple mode, if user use Ctrl or Shift key to select multiple cells, how can I retrieve the selected cells?


thanks,


1 Reply

VB Vinitha Balasubramanian Syncfusion Team July 12, 2022 01:09 PM UTC

Hi Customer,


Greetings from Syncfusion support.


Query : How to get selected cells on multi-select mode in grid


We have analyzed your query, you want to get the selected cell index of selected records in multi-selection mode. We have created a sample and to achieve your requirement using cellSelected event. On that event, we can get the selected cell index using getSelectedRowCellIndexes method.


Kindly refer the below code and sample for your references.


[index.js]

cellSelected(args) {

    console.log(args.selectedRowCellIndex);

    if (this.grid) {

      /** Get the selected row indexes */

      var selectedrowindex = this.grid.getSelectedRowCellIndexes();

      console.log(selectedrowindex);

    }

 }


Sample link : https://stackblitz.com/edit/react-yuwfuk-bfarw6?file=index.js,index.html


Kindly refer the below provided screenshot for further references.



Reference API link : https://ej2.syncfusion.com/documentation/api/grid/#cellselected


              https://ej2.syncfusion.com/documentation/api/grid/#getselectedrowcellindexes


If it doesn’t meet your requirement, kindly share your exact requirement with us to validate your query further.


Regards,

Vinitha Balasubramanian


Loader.
Up arrow icon