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.

ngx-datatable formArray remove row, desynchronized table values

See original GitHub issue

I’m submitting a …

[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 I have a ngx-datatable in binding with a formarray and the single cell are constructed with ng-template ngx-datatable-cell-template.

When I remove one item from the datable and the underline formarray with the follow code, the table became desynchronised.

The form control show a different value respect the underline formgroup.

list of items before the remove

list of items after removing line 35

Expected behavior

When removing item from the table, the column with in binding formcontrol not became desincronized.

Reproduction of the problem

Code deleting the row

let index = this.datarows.indexOf(this.selected[0])
if (index>-1){                        
      this.datarows.splice(index,1);
      this.controls.removeAt(index);

      this.datarows = [...this.datarows];        
      this.controls.patchValue(this.datarows);     
}
  • Browser: Chrome 67.0

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:11

github_iconTop GitHub Comments

2reactions
taivucommented, Nov 20, 2018

also found out: if i leave the route and return, the values get updated to the correct thing. testing this further, i set a boolean variable test in my component, and set an ngIf on the fields that are desynced. if i remove the row, it becomes desynced, but then if i toggle the test variable, it will resync back.

Angular 7.0.4

2reactions
ni3stackcommented, Aug 27, 2018

do we have any alternative for this?? i’m facing the same issue when deleting first row it always delete the last one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove rows with ngx-datatable - angular - Stack Overflow
Your stacklitz example show how to remove first row with different sites names. I want to keep all my elements with "Site1" as...
Read more >
is_array javascript Code Example - Code Grepper
let names=['Jhon','David','Mark']; console.log(Array.isArray(names)); // true let user={id:1,name:'David'}; console.log(Array.isArray(user)); // false let ...
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