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

[Solved] get_text() on treenode works ok but get_value() returns null

4 Answers 384 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
rdochert
Top achievements
Rank 1
rdochert asked on 25 Jan 2008, 03:58 AM
hi,
i seem to be having a problem extracting the ID of a tree node when a context menu item is selected over it. everything else works ok but the client side javascript to extract the id get_value() - returns a null. if i change the client side to get_text(), i am correctly given the text of the tree node.
any ideas?
i've converted a lot of my app to prometheus now and most of it has been quite smooth. but radtreeview and the context menus have changed quite a lot - particularly on the client side.
cheers
rob

                function onClientContextMenuItemClicked(sender, args)
                {
                    var menuItem = args.get_menuItem();
                    var treeNode = args.get_node();

                    switch(menuItem.get_value())
                    {
                        case "PROPS":
                            __doPostBack('propsPage', treeNode.get_value());
                                break;
                        case "STYLE":
                            showStyles(treeNode.get_value());
                                break;
                        case "RSTYLE":
                            __doPostBack('rootstylePage', treeNode.get_value());
                                break;
                        case "ADD":
                            __doPostBack('addPage', treeNode.get_value());
                                break;
                        case "EDIT":
                            __doPostBack('editPage', treeNode.get_value());
                                break;
                        case "VIEW":
                            previewPage(treeNode.get_value());
                                break;
                        case "DELETE":
                            if (confirm("Are you sure? This action cannot be undone!"))
                            {
                            __doPostBack('deletePage', treeNode.get_value());
                            }
                                break;
                    }
                }



<telerik:RadTreeView ID="RadTreeView1" runat="server" DataSourceID="sqlTemplateSections"
DataTextField="wel_name" DataFieldID="wel_keyval" DataFieldParentID="wel_parent_keyval"
OnClientContextMenuItemClicked="onClientContextMenuItemClicked"
OnClientContextMenuShowing="onClientContextMenuShowing"
>

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 25 Jan 2008, 08:01 AM
Hi rdochert,

The get_value() method will return non-null if you have set the Value server-side property of that node beforehand.

Kind regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
rdochert
Top achievements
Rank 1
answered on 25 Jan 2008, 09:04 AM
thanks but as you can see from the treeview definition, it is a databound control and i have set the DataFieldID to a column from the database. can i not extract this ID value on the client side? i was able to do this with the asp.net version of this control.

can you please explain how i can access this value on the client side?
thanks,
rob
0
rdochert
Top achievements
Rank 1
answered on 25 Jan 2008, 09:06 AM
thanks but as you can see from the treeview definition, it is a databound control and i have set the DataFieldID to a column from the database. can i not extract this ID value on the client side? i was able to do this with the asp.net version of this control.

can you please explain how i can access this value on the client side?
thanks,
rob
0
Atanas Korchev
Telerik team
answered on 25 Jan 2008, 09:08 AM
Hi rdochert,

DataFieldID is used only for the purpose of databinding. You can however set the DataValueField property to the same value of DataFieldID. Now the Value property of all databound nodes will be populated with data from the ID column.

<telerik:RadTreeView ID="RadTreeView1" runat="server" DataSourceID="sqlTemplateSections"
DataTextField="wel_name"
DataValueField="wel_keyval" DataFieldID="wel_keyval" DataFieldParentID="wel_parent_keyval"
OnClientContextMenuItemClicked="onClientContextMenuItemClicked"
OnClientContextMenuShowing="onClientContextMenuShowing"
>

I hope this helps,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
rdochert
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
rdochert
Top achievements
Rank 1
Share this question
or