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.

Splice item from [rows] not removing correct row

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
dtarvincommented, Aug 29, 2018

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; }

0reactions
mbrucknercommented, Jun 25, 2019

@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.

Read more comments on GitHub >

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

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