This question is locked. New answers and comments are not allowed.
Greetings,
How can one get the value of the parent node of a node. I tried the following:
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
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 :)
Regards,
Peter
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
Thanks for your prompt reply and hope you have a better answer,
Eugene
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
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.
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
OK. Your solution worked except that the characters "> div " needed to be removed.
Thanks,
Eugene