Re-ordering rows does not cause view to update
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
Current behavior If the input rows are re-ordered, the visualization of the table is not updated.
Expected behavior If the input rows are re-ordered, I would expect the view to reflect this change.
Reproduction of the problem In the following component, select the second row and click the “Up” button.
Expected behaviour: first row in table is “b”, second row in table is “a” Actual behaviour: Table does not change (first row “a”, second row “b”).
import { Component } from '@angular/core'
@Component({
selector: 'table-test',
template: `
<swui-datatable
class="material"
[rows]="rows"
[selected]="selected"
[selectionType]="'single'">
<swui-datatable-column name="Prop" prop="prop" [sortable]="false">
</swui-datatable-column>
</swui-datatable>
<button (click)="clickUp()">Up</button>
`
})
export class StartComponent {
selected :any[] = []
rows = [ { prop: 'a' }, { prop: 'b' } ]
clickUp() {
console.log(JSON.stringify(this.rows))
let ix = this.getSelectedIx()
let arr = [ ...this.rows ]
arr[ix-1] = this.rows[ix]
arr[ix] = this.rows[ix-1]
this.rows.splice(0, this.rows.length, ...arr)
console.log(JSON.stringify(this.rows))
}
getSelectedIx() {
return this.selected[0]['$$index']
}
}
What is the motivation / use case for changing the behavior? The user should be able to choose the order of a table arbitrarily.
-
Table version: 2.2.3
-
Angular version: 2.4.0
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (8 by maintainers)
Top Results From Across the Web
Incorrect UI update after reordering rows in ... - Stack Overflow
I had successful experience of reordering rows in a table that was not reading Realm objects. So I am not sure if this...
Read more >Managing the Reordering of Rows - Apple Developer
Describes how to create and manage table views for applications running iOS.
Read more >Update all rows when sort/ordering value is changed for ...
I have considered using floating point values instead, which would make it possible to simply create a new value between two existing values, ......
Read more >Row reordering after sorting — DataTables forums
The only issue that it seems I have is that internally DataTables doesn't update this column in its cache, so for instance after...
Read more >How to Sort in Excel Rows or Columns Avoid Sort Problems
Sorting a Row To sort by a row, follow these steps: Select one cell in the row you want to sort. Press Ctrl...
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
Is there a workaround to force redraw?
From my point of view, this issue is still open - I do not believe that
onPush
is relevant here, see above.Is there any more information I can provide?