Hi Tingting,
Thanks for contacting Syncfusion support.
Query: If I use the Box mode to select some cells, how
do I get selected cells value?
By using getSelectedRowCellIndexes and getCurrentViewRecords
methods of Grid, you can get the currently selected cell values. Find the below
code and sample for more information.
getSelectedRowCellIndexes: https://ej2.syncfusion.com/react/documentation/api/grid/#getselectedrowcellindexes
getCurrentViewRecords: https://ej2.syncfusion.com/react/documentation/api/grid/#getcurrentviewrecords
|
getSelectedCellValues(args) {
// get the
selected cell indexes
var selectedRowCellIndexs = this.grid.getSelectedRowCellIndexes();
var selectedCellValues = [];
// get the
current view data
var currentViewData = this.grid.getCurrentViewRecords();
var grid = this.grid;
// get the
currently selected cell values
selectedRowCellIndexs.map((item) => {
var rowData = {};
item.cellIndexes.map((x) => {
var col = grid.getColumnByIndex(x);
if (col.visible) {
rowData[col.field] = currentViewData[item.rowIndex][col.field];
}
});
selectedCellValues.push(rowData);
});
console.log(selectedCellValues);
}
|
Sample: https://stackblitz.com/edit/react-hn9xaq?file=index.js
Please let us know if you have any concerns.
Regards,
Rajapandiyan S