Updating sorted data causes shuffle behavior
I've written up a plnkr here showcasing the issue.
https://plnkr.co/edit/thxW3u?p=preview
Steps to reproduce are as follows:
- Bind a data set with a field that won't change often between cycles
- Sort by the field (in this case, sort by Class, it doesn't change much)
- Initiate a change to the data (in this plunkr, click The Button)
- Now cause an event cycle (move your mouse over the table or something)
Long and short of it is that the data rows in the dataTable will all start to "jumble" around.
Any update on this bug? Is it likely to make it into Beta 9?
I've replicated and added a fix that seems to prevent resort which is main cause of shuffle.
Ok - so does that mean it now no longer re-sorts correctly if the underlying data changes?
E.g. Apply sort by date, change a date value and it won't be sorted until you manually re-apply sort on data column?
No, it should still sort when underlying data changes, but only once, with this bug it was sorting even on mouseover :)
Great Thanks for that - it is a really nice feature to have.
This appears to be happening in 4.1.3 and 4.2.1
This issue is still present in 4.3.0
For anyone still running into this... In my case, this bug presented itself via a DataTable that had the immutable property set to false. After sorting the DataTable and then altering one of the records, the shuffling behavior appeared while moving the mouse (i.e. during change detection cycles). I was able to fix my particular problem by making a ViewChild of the DataTable, and then setting the preventSortPropagation property of the DataTable to true after altering the record.
export class MyComponent {
@ViewChild('dt') dt: DataTable;
updateRecord() {
// call to my service to update my record
this.dt.preventSortPropagation = true;
}
}