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.

Re-ordering rows does not cause view to update

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

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:closed
  • Created 7 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
achimhacommented, May 15, 2017

Is there a workaround to force redraw?

1reaction
frehncommented, Jan 13, 2017

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?

Read more comments on GitHub >

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

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