1

I'm using angular-ui-tree.

The object I have in my treeview has a sort index. I am looking for a way to bind this sort index to the desIndex of the treeview scope, using something similar to this:

ui-tree-desIndex="node.sortIndex"

desIndex is the treeview node's index and node.sortIndex is my object's index.

I want it to sort my list by my objects' values, and when I move an object in the treeview the scope will update that object's index like this:

<div ui-tree="treeOptions" callbacks="treeOptions">
    <ol ui-tree-nodes="" data-nodrop-enabled="true" ng-model="rootNodeLst" callbacks="treeOptions" id="tree-root">
        <li ng-repeat="node  ui-tree-desIndex="node.sortIndex" in rootNodeLst" callbacks="treeOptions" ui-tree-node ng-include="'nodes_renderer.html'"></li>
    </ol>
</div>

The code above isn't working, how can I fix it?

Graham
  • 7,431
  • 18
  • 59
  • 84
DaCh
  • 921
  • 1
  • 14
  • 48

2 Answers2

1

Change this

<li ng-repeat="node  ui-tree-desIndex="node.sortIndex" in rootNodeLst" callbacks="treeOptions" ui-tree-node ng-include="'nodes_renderer.html'"></li>

To this

<li ng-repeat="node in rootNodeLst" ui-tree-desIndex="node.sortIndex" callbacks="treeOptions" ui-tree-node ng-include="'nodes_renderer.html'"></li>

For starters, to get your ng-repeat working.

Then, if ui-tree-desIndex does not get the value set, you can try:

ui-tree-desIndex="{{node.sortIndex}}" or ng-attr-ui-tree-desIndex="{{node.sortIndex}}"

See this JSFiddle.

Arg0n
  • 8,283
  • 2
  • 21
  • 38
  • I am indeed sry that i mess up my repeater, but the `ui-tree-desIndex="node.sortIndex"'` was just a sample of what i think i could be. the ui-tree-desIndex isn't something that works. – DaCh Nov 26 '15 at 21:24
0

Funny thing.

Found out that the way im building the treeview with the nested html modify my $index to show this sort number, so, anyway. thanks for your time and helå

DaCh
  • 921
  • 1
  • 14
  • 48