angular-data-table icon indicating copy to clipboard operation
angular-data-table copied to clipboard

Row are not re-sorted when data change

Open tomaash opened this issue 8 years ago • 6 comments

I there are some new data bound to the rows property, then table keeps its current sorting marks, but the new data are not re-sorted. I've been able to fix this with a trivial patch, but I'm not sure if I'm not missing something. I just removed the watch() call to keep the watch even after constructor ran. What I changed: javascript

// default sort
var watch = $scope.$watch('dt.rows', (newVal) => {
  if(newVal){
    // just commented this out
    //watch(); 
    this.onSorted();
  }
});

tomaash avatar Apr 07 '16 11:04 tomaash

Thats kind a pricey fix :S ... can u make a demo ( plunkr/fiddle/etc ) showing the issue and the fix?

amcdnl avatar Apr 07 '16 12:04 amcdnl

I know that it's performance hit. Would it be enough for you to just take a look here? https://melite2-dev.herokuapp.com/#/people/me/profile/documents/Application try to sort a column, and then change a section. The sort icon will stay, data will update, but it will no longer be sorted by the specified orded.

tomaash avatar Apr 07 '16 13:04 tomaash

~~Now I narrowed it down. This problem does NOT happen when sortType: 'single'.~~ False alarm, still broken even with 'single'.

tomaash avatar Apr 07 '16 13:04 tomaash

Less pricey fix would be to allow somehow to tell the data-table directive to resort itself. It could listen to $broadcast or something.. actually isn't there some way to force resort even with existing version?

tomaash avatar Apr 08 '16 11:04 tomaash

In my use case, I splice all my data out of the table and re-insert it sorted. My use case uses server-side sorting though.

amcdnl avatar Apr 08 '16 11:04 amcdnl

Any updates @tomaash

amcdnl avatar Jul 08 '16 21:07 amcdnl