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

Dropdowntree with Checkboxes webservice expand - setting Checked=true

4 Answers 135 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Dominic
Top achievements
Rank 1
Dominic asked on 16 Mar 2015, 12:07 PM
I have a AJAX DropDownTree that has checkboxes on it.

When I use a webservice to load child nodes in the RadDropDownTree I need to be able to set Checked=true on some of the child DropDownDataNodes that I create.

When creating the nodes in the webservice code is their any way I can access the Checked property on the DropDownDataNodes as the Checked property doesn't seem to be available?


Or if I could hook into an event that fires when the webservice call ends...could I set the new child items Checked property then?

4 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 19 Mar 2015, 07:57 AM
Hello Dominic,

The RadTreeNodeData object that should be used in a WebService scenario, exposes the Checked property, which should reflect on the checked state of the Node.

However, the OnClientNodeDataBound client-side event of the RadTreeView is triggered for each Node, which is databound with a WebService scenario. You can use this event to manage the Checked state of the currently evaluated Node. More information on the event could be found in our help article below:

http://www.telerik.com/help/aspnet-ajax/treeview-onclientnodedatabound.html

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Dominic
Top achievements
Rank 1
answered on 19 Mar 2015, 10:01 AM
Thank you for your reply.

So yes, when I hook in the RadTreeNodeData object into the webservice I can set the Checked property and this is indeed reflected in the DropDownTree once the webservice call has ended.

However the SelectedValue and SelectedText of the DropDownTree is not updated.

Is their a client side method I need to call to force the update - like the server-side SyncEmbeddedTree()?
0
Nencho
Telerik team
answered on 24 Mar 2015, 09:17 AM
Hello Dominic,

Indeed the checked entry is not listed in the input of the control. In such scenario, the child items are loaded on demand and it is not quite expected to have something set as checked and placed in the input of the control, when certain node is expanded.

However, I would suggest you the following workaround, in order to achieve the desired functionality :

In the WebService, you can use the Attributes collection of the currently evaluated node, in order to set a custom property  e.g. ShouldBeChecked. In addition, you should hook the OnClientNodeDataBound client-side event of the embedded tree and handle the function at client-side. Thus, you can check this attribute and use jQuery to imitate a user interaction.

in the WebService :
childNode.Attributes["ShouldBeChecked"] = "True"

at Page_Load event of the page, where the control is placed:
RadDropDownTree1.EmbeddedTree.OnClientNodeDataBound= "OnClientNodeDataBound"

the OnClientNodeDataBoumd function:
<script type="text/javascript">
            function OnClientNodeDataBound(sender, args) {
                var node = args.get_node();
                var ShouldBeChecked = node.get_attributes().getAttribute("ShouldBeChecked")
 
                if (ShouldBeChecked) {
                    $telerik.$(node.get_element()).find(".rtChk")[0].click();
                }
            }
        </script>


Regards,
Nencho
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Dominic
Top achievements
Rank 1
answered on 25 Mar 2015, 09:48 AM
Yes that did the trick.

Unfortunately the performance of doing what you suggested was really slow for 100+ items (which is common for my set up).
I chose to implement a treeview in a combobox in the end and the performance is notably faster.

Thank you for your help in any case,

cheers

Tags
DropDownTree
Asked by
Dominic
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Dominic
Top achievements
Rank 1
Share this question
or