Splice item from [rows] not removing correct row
See original GitHub issueI’m submitting a … (check one with “x”)
[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
Current behavior
<ngx-datatable #table class="material" [rows]="filteredItems"
The array filteredItems contains 10 items. If I use splice to remove element two, the ngx-datatable re-renders but it removes the bottom-most row of the table.
Expected behavior
Only item two should be removed.
Reproduction of the problem Upgrading to 11.1.7 introduced the issue. Worked as expected with 11.0.4
What is the motivation / use case for changing the behavior? No change. Should exhibit same behavior as 11.0.4
Please tell us about your environment:
-
Table version: 11.1.7
-
Angular version: 5.0.0
-
Browser: Chrome
-
Language: TypeScript 2.6.2
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
splice not removing element correctly - angular - Stack Overflow
I'm using ngFor let let i = index; then I'm passing the i into the splice, which removes all json elements, but one....
Read more >Remove or keep rows with errors (Power Query)
To remove errors from specific columns, select the columns by using Ctrl + Click or Shift + Click. The columns can be contiguous...
Read more >Add or remove rows and columns in Numbers on Mac
In Numbers on your Mac, add, delete, rearrange, or hide rows and columns in a table, and freeze header rows.
Read more >How to Delete Rows in R? Explained with Examples
For example, to delete the second and third row in R, use -c(1, 3) , and it will return the data frame without...
Read more >How to delete rows in Excel using shortcuts or VBA macro
If you have a simple Excel list that has no additional information to the right, you can use the delete row shortcut to...
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
The ‘_.reject’ only works if you are using a certain library. However, someone helped me with this. Apparently the problem is that you first have to set the array of rows to another variable and then do the slice from that variable, then reset the array of rows to the variable.
So: deleteFilteredItem(index) { let temp = […this.filteredItems]; temp.splice(index, 1); this.filteredItems = temp; }
@Kligerr This is because using the spread operator that way creates a new array which gets detected using the
OnPush
change detection strategy. The array is still the same even if you temporarily assign it to a local variable.