GridService.getSelectedRows return a direct reference of the underlying slickgrid internal array
See original GitHub issueI’m submitting a Bug report
Your Environment
Software | Version(s) |
---|---|
Angular | 8 |
Angular-Slickgrid | 2.x |
Context
I noticed that GridService.getSelectedRows return direct reference of underlying slickgrid internal array.
However, I’m not sure whether this is the intended behavior, but it causes some subtle issue when I try to manipulate the return value as shown below:
this.columnDefinitions2 = [
{
id: 'title', name: 'Title', field: 'title',
sortable: true,
type: FieldType.string,
filterable: true,
onCellClick: (e: Event, args: OnEventArgs) => {
//OK - Able to select the clicked row correctly
// const selectedRows = [...this.angularGrid2.gridService.getSelectedRows()];
//NOT OK - Failed to select the clicked row correctly
const selectedRows = this.angularGrid2.gridService.getSelectedRows();
// Toggle the clicked row
const deleteIndex = selectedRows.indexOf(args.row);
if (deleteIndex >= 0) {
selectedRows.splice(deleteIndex, 1);
} else {
selectedRows.push(args.row);
}
this.angularGrid2.gridService.setSelectedRows(selectedRows);
}
},
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
SlickGrid javascript get current row data - Stack Overflow
First, the getSelectedRows() function returns an Array of the selected column numbers. The way you are trying will return undefined , since that...
Read more >H5 Scripting - Developing for Infor Smart Office
The underlying grid is an instance of a SlickGrid that exposes a method for setting the row selection. In your TypeScript you'll need...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Will use the spread workaround for time being. Many Thanks
The spread operator makes a deep copy, so it seems that you have pointer issues. I’ll close the issue for now and if more details comes up to help this issue then I can reopen it.