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

How to locate the node when using template

6 Answers 90 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
David zhao
Top achievements
Rank 1
David zhao asked on 19 Jun 2010, 12:59 PM
[aspx]
<telerik:RadTreeView ID="RadTreeView1" Runat="server" >
                <NodeTemplate>
                        <div>
                            <asp:CheckBox ID="CheckBox_IsChoosed" runat="server" onclick="OnCheckedChanged()"/>
                            ..........(other controls)
                        </div>
                </NodeTemplate>
</telerik:RadTreeView>

[My Question]
I want to use client javascript codes to deal with the CheckBox'  checked changed event. But in the javascript OnCheckedChanged(), how can I locate the node in which the CheckBox is changed?
If I used the RadTreeView' OnClientNodeClicked, I have no idea of way to make sure which control in the template fire the OnClientNodeClicked.

Thanks

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jun 2010, 08:26 AM
Hi David,

Try out the following approach:

Iterate through the RadTreeNodes from server side and attach the onclick event from code. Then you will be able to pass TreeNode text/value to client event handler. Now in the event handler, get the parameter passed and access the corresponding node using any of the methods findNodeByText/findNodeByValue based on value passed.


Hope this help,
Shinu.
0
David zhao
Top achievements
Rank 1
answered on 21 Jun 2010, 09:22 AM
To Shinu:
    Thank you for your reply. But I don't understand your suggestion.
    My javascript code to handle the CheckBox's client checked changed event can be fired , but I don't know how to locate the node in which the CheckBox is changed when using javascript function. If I iterated throug the RadTreeNodes from server side when some CheckBox was changed, I don't need the client javascript code at all.
0
Nikolay Tsenkov
Telerik team
answered on 23 Jun 2010, 03:18 PM
Hello David zhao,

Just a suggestion:

- Why don't use the check-boxes provided by the treeView (just set CheckBoxes="true" in the markup of the tree), trap the event OnClientNodeChecked() and get the node that is being checked by args.get_node()?

And you still can use template!

Hope this is going to help you!


Regards,
Nikolay Tsenkov
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
David zhao
Top achievements
Rank 1
answered on 24 Jun 2010, 04:47 PM
Thank the telerik admin for your suggesion

The reasons  for using node template, not CheckBox built in the RadTreeView, is that I have to put two CheckBoxs in a node at the same time.
Furthermore, the CheckBox built in the RadTreeView is some small. My client has complained that he hardly saw the tick in the CheckBox.
Is there a way to change the style of the CheckBox built in RadTreeView?

So, the telerik admin, if I choose to use the node template with CheckBox , when I check the CheckBox,  is there a way to locate the node by using client js codes?
0
Nikolay Tsenkov
Telerik team
answered on 29 Jun 2010, 03:41 PM
Hello David,

Is there a way to change the style of the CheckBox built in RadTreeView?
- No, or not for all browsers. I think only Opera supports such an operation. This is because these checkboxes are the default rendered by the browser.

...is there a way to locate the node by using client js codes?
- Yes, there is! You can use the method _extractNodeFromDomElement over the treeView object.

Hope this is going to help you!


Regards,
Nikolay Tsenkov
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
David zhao
Top achievements
Rank 1
answered on 30 Jun 2010, 09:25 AM
Thank the telerik admin for your suggesion.
I deside to use server code to deal with my problem for time reason.

Tags
TreeView
Asked by
David zhao
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
David zhao
Top achievements
Rank 1
Nikolay Tsenkov
Telerik team
Share this question
or