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

Clear Selection

4 Answers 205 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Balaji
Top achievements
Rank 1
Balaji asked on 27 Aug 2013, 05:18 AM
Hi,

In dropdownlist there is an option to Clear Selection. Is there a similar functionality in dropdowntree to clear what was last selected and display the default message?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 27 Aug 2013, 07:19 AM
Hi Balaji,

Please try the following JavaScript to clear the selection and display the default message.

JavaScript:
<script type="text/javascript">
    function OnClientClicked(sender, args) {
        var dropdowntree1 = $find('<%=RadDropDownTree1.ClientID %>');
        dropdowntree1.get_entries().clear();
    }
</script>

Thanks,
Shinu.
0
Kate
Telerik team
answered on 27 Aug 2013, 07:26 AM
Hi Balaji,,

You ca use the approach that Shinu provided or the Clear button that is specially designed for this purpose as  fully explained here.  

Regards,
Kate
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Balaji
Top achievements
Rank 1
answered on 27 Aug 2013, 08:12 AM
Hi Kate, Shinu,

Thank you for the response.

Actually the requirement is to clear the selection from Code behind. 

Ex: I have a dropdowntree with below structure and I dont have checkboxes and so the clear button as well.
Country (Level 1)
---State (Level 2)
-------City  (Level 3)

I have mapped city for each employee. On employee selection I would like to load the tree with selected value. If there is no city mapped against a employee, I need to clear the selection and show the default message "Select City".

For each employee, I read the data from database and display it to the user. When there is a value, I can set it as selected value and its works perfect. But when there is no data (NULL value from database), I am unable to clear the selected value of the previous employee.

Hope I am clear with my query.

Thanks,
Balaji.
0
Kate
Telerik team
answered on 29 Aug 2013, 01:25 PM
Hello Balaji,

If you are trying to clear the items on button click for example you can find the control, access its selected entries and clear them by using the code below:

C#
RadDropDownTree1.Entries.Clear();

Regards,
Kate
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
DropDownTree
Asked by
Balaji
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Kate
Telerik team
Balaji
Top achievements
Rank 1
Share this question
or