Reputation: 6862
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"
).
Upvotes: 0
Views: 1594
Reputation: 30671
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.
Upvotes: 2