Dropdowntree with Checkboxes webservice expand - setting Checked=true

5 posts, 0 answers
  1. Dominic
    Dominic avatar
    7 posts
    Member since:
    Dec 2010

    Posted 16 Mar 2015 Link to this post

    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?

  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 19 Mar 2015 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dominic
    Dominic avatar
    7 posts
    Member since:
    Dec 2010

    Posted 19 Mar 2015 in reply to Nencho Link to this post

    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()?
  5. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 24 Mar 2015 Link to this post

    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.

     
  6. Dominic
    Dominic avatar
    7 posts
    Member since:
    Dec 2010

    Posted 25 Mar 2015 in reply to Nencho Link to this post

    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

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017