i have problem reordering item in table.
i'm using angularjs + ngtable , ui-sortable.
the problem reordered data ist displayed in wrong order after reloading. data correct , order values correct shown in wrong order. happening after reload table/view after reordering items. don't happen always. example if move:
1 4
5 2
1 8
3 1
2 6
should lead following order:
4,3,1,6,7,5,8,2,9,10 after reloading items in order:
4,1,3,6,7,5,9,10,8,2
but items have correct order values assigned.
can check out on plunker https://plnkr.co/edit/hih0pnbbjlmzerhzkad9
reorder items described above , click on button reload view.
i found out happening during ng-repeat directive on code block in angularjs: // if have seen object, need reuse // associated scope/element
nextnode = previousnode; // skip nodes pending removal via leave animation { nextnode = nextnode.nextsibling; } while (nextnode && nextnode[ng_removed]); if (getblockstart(block) !== nextnode) { // existing item got moved $animate.move(getblocknodes(block.clone), null, previousnode); } previousnode = getblockend(block); updatescope(block.scope, index, valueidentifier, value, keyidentifier, key, collectionlength);
there going on wrong sibling, leads move data different position. data passed ng-repeat seems correct. objects have correct new order value.
you ask, why reload when data display correctly? thats happening example if want sort clicking columns.
edit: seems model list not updated. if use $scope.$apply() @ end of stop() seems work. leads performance issue when having more data due calling $scope.$apply() when dropping every row. when use $scope.$apply() outside of stop() doesn't work. :(
i don't understand why need call $scope.apply because not changing object outside of scope.
so, question how apply model change without calling $scope.$apply() on every stop() event once @ end/before reloading table? if call $scope.$apply on btn click, doesn't work.
edit/solved: ok. problem calling $apply() sortable initialized through jquery. if use correctly ui-sortable directives call digest internally dont need manually. solve loading issue after refactoring code. in end apply()/digest loop doesnt bother me anymore.
Comments
Post a Comment