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?

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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å

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.