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

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

3 Answers 68 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Balageetha
Top achievements
Rank 1
Balageetha asked on 22 Aug 2014, 06:56 AM
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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 22 Aug 2014, 09:17 AM
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.
0
Balageetha
Top achievements
Rank 1
answered on 22 Aug 2014, 09:53 AM
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.
















0
Shinu
Top achievements
Rank 1
answered on 25 Aug 2014, 03:37 AM
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.
Tags
DropDownTree
Asked by
Balageetha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Balageetha
Top achievements
Rank 1
Share this question
or