question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GridService.getSelectedRows return a direct reference of the underlying slickgrid internal array

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
whtan98commented, Sep 27, 2019

Will use the spread workaround for time being. Many Thanks

0reactions
ghiscodingcommented, Sep 27, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found