Unable to Clear a Rad Dropdown tree that is used as a User control

4 posts, 1 answers
  1. Balageetha
    Balageetha avatar
    12 posts
    Member since:
    May 2014

    Posted 22 Aug 2014 Link to this post

    Hello,


                       I have used the Rad drop down tree as a user control as follows,

                                     <rad:RadDropDownTree ID="rddtArea" runat="server" DropDownSettings-CloseDropDownOnSelection="true"
         EnableFiltering="true" FilterSettings-Highlight="Matches"
        DropDownSettings-Height="200" Skin="Outlook">
    </rad:RadDropDownTree>

                     and i have used this user control in another page and i am trying to clear the Drop down tree value using java script but i didn't get the solution.

                   pls help me soon.


    Thanks in Advance.
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Aug 2014 in reply to Balageetha Link to this post

    Hi Balageetha,

    Please try the below sample code snippet which works fine at my end.

    ASPX:
    <uc1:DropDownTree ID="DropDownTree1" runat="server" />
    <telerik:RadButton ID="rbtnClearValue" runat="server" Text="Clear DropDownTree Text"
        AutoPostBack="false" OnClientClicked="clearDropdownTree">
    </telerik:RadButton>

    ASPX Page JavaScript:
    function clearDropdownTree(sender, args) {
        var dropTree = document.getElementById('<% =this.DropDownTree1.DropDownTree %>');
        dropTree.control.get_entries().clear();
    }

    ASCX:
    <telerik:RadDropDownTree ID="rdroptreeDetails" runat="server" DropDownSettings-CloseDropDownOnSelection="true" EnableFiltering="true" FilterSettings-Highlight="Matches" DropDownSettings-Height="200" Skin="Outlook" DataFieldID="id" DataFieldParentID="parentid" DataTextField="text" DataSourceID="sqldsDetails">
    </telerik:RadDropDownTree>

    ASCX Page C#:
    public string DropDownTree { get { return this.rdroptreeDetails.ClientID; } }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Balageetha
    Balageetha avatar
    12 posts
    Member since:
    May 2014

    Posted 22 Aug 2014 in reply to Shinu Link to this post

    Hi Shinu,

                  Thanks a lot.It is working fine.

                  But it is clearing the Default Message "All". I have given the Default messgae in the Code behind since it is giving some error if the Default message is given in the Design code.

                 how can i set the Selected Index in javascript for that Drop down tree.
















  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Aug 2014 in reply to Balageetha Link to this post

    Hi Balageetha,

    As for your first question such an issue is not expected, after removing the entry data it will show the default message. This is the default behavior of the control. Please try the below code snippet to select the entry by index.

    JavaScript:
    function clearDropdownTree(sender, args) {
        var dropTree = document.getElementById('<% =this.DropDownTree1.DropDownTree %>');
        dropTree.control.get_entries().clear();
        dropTree.control.get_embeddedTree()._findItemByHierarchicalIndex("1").set_selected(true);
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
Back to Top