Clear Selection

5 posts, 0 answers
  1. Balaji
    Balaji avatar
    2 posts
    Member since:
    Aug 2013

    Posted 27 Aug 2013 Link to this post

    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?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Aug 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 27 Aug 2013 Link to this post

    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.
  5. Balaji
    Balaji avatar
    2 posts
    Member since:
    Aug 2013

    Posted 27 Aug 2013 Link to this post

    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.
  6. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 29 Aug 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017