0

I have a treeview with check box. When a check box is clicked, I need, client-side, to know the node level of the node just selected. exemple:

[ ] Node (level 1)
  [x] Node (level 2)
  [ ] Node (level 2)
  [ ] Node (level 2)
  [ ] Node (level 2)
[ ] Node (level 1)
  [ ] Node (level 2)
  [ ] Node (level 2)
  [ ] Node (level 2)

I dont see any property in the event parameter that could tell the level of the node. A viable workaround would be to add, server side, an attribute to the node to indicate the level (for exemple data-level="1").

1 Answer 1

2

The following code should return the level of a node:

var level = $(e.item).parents(".t-item").length;

What it does is to find all parent elements that have the "t-item" CSS class which happen to be the parent nodes.

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

1 Comment

Well that seems like it would works. I would have prefered to add a tag to the item for the level. My colleague is sick today so I will not try it until tomorrow.

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.