This is a migrated thread and some comments may be shown as answers.

[Solved] Treeview parent node

4 Answers 221 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eugene
Top achievements
Rank 1
Eugene asked on 16 Apr 2010, 10:40 PM
Greetings,
    How can one get the value of the parent node of a node.  I tried the following:

$(e.item.parentNode).find(

':input[name*="Value"]').val();  This gives me the same value as

 

$(e.item).closest(

'.t-item').find(':input[name*="Value"]').val();

Thanks in advance,

 

 

Eugene

4 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 19 Apr 2010, 09:15 AM
Hi,

closest  method looks first in the current html element, which in this case is the TreeView item. Thus you will never find the parent. To achieve your goal you need to combine your two samples :)
$(e.item.parentNode).closest('.t-item').find(':input[name*="Value"]').val(); 

Regards,
Peter


0
Eugene
Top achievements
Rank 1
answered on 19 Apr 2010, 04:27 PM
Hello Peter,
    Your answer, although looking good on paper, unfortunately did not produce the expected results.  Whereas the code snippet

var

 

nodeSelected = $(e.item).closest('.t-item').find(':input[name*="Value"]').val(); gives me the selected node, the code snippet

 

var

 

parentID = $(e.item.parentNode).closest('.t-item').find(':input[name*="Value"]').val(); produces the same ID number, as demonstrated by alert(nodeSelected + " " + parentID).  The code to find the parent's node ID was cut and pasted from your sample in your last reply.

 


Thanks for your prompt reply and hope you have a better answer,
Eugene
0
Alex Gyoshev
Telerik team
answered on 20 Apr 2010, 07:41 AM
Hello Eugene,

Try the following:
    $(e.item).closest('.t-item').parent().closest('.t-item').find('> div :input[name*="Value"]').val();


Kind regards,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Eugene
Top achievements
Rank 1
answered on 20 Apr 2010, 05:00 PM
Hello Alex,
    OK.  Your solution worked except that the characters "> div " needed to be removed.
    
Thanks,
Eugene
Tags
TreeView
Asked by
Eugene
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Eugene
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or