Selecting one single node

7 posts, 1 answers
  1. César
    César avatar
    14 posts
    Member since:
    Sep 2013

    Posted 06 Nov 2013 Link to this post

    Hi,

    Is there any way to configure the control to only allow to select one single item? I.e. when selecting one item, deselecting the rest of them? 

    If not, which would be the best way?

    Thanks
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Nov 2013 Link to this post

    Hi César,

    I guess you are using CheckBoxes to select an item of RadDropDownTree. Please have a look into the code snippet to allow only one item to select at a time.

    ASPX:
    <telerik:RadDropDownTree ID="RadDropDownTree" runat="server" DataSourceID="SqlDataSource1"
        DataFieldID="id" DataFieldParentID="parentid" DataTextField="text" CheckBoxes="SingleCheck" OnClientEntryAdding="OnClientEntryAdding1">
    </telerik:RadDropDownTree>

    JavaScript:
    <script type="text/javascript">
        function OnClientEntryAdding1(sender, args) {
            if (sender.get_entries().get_count() > 0) {
                sender.get_entries().clear();
            }
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. César
    César avatar
    14 posts
    Member since:
    Sep 2013

    Posted 07 Nov 2013 Link to this post

    It perfectly works.

    I also found that setting the property "CheckBoxes" to none, was covering the requirement, but was hiding the CheckBoxes:

    <telerik:RadDropDownTree ID="RadDropDownTree" runat="server" DefaultMessage="Please select" CheckBoxes="None"  Width="340px"
                DataFieldID="ID" DataFieldParentID="ParentID" DataTextField="Text" DataValueField="Value" 
                TextMode="Default" ExpandNodeOnSingleClick="false">
                <DropDownSettings AutoWidth="Enabled" />
            </telerik:RadDropDownTree>


    I still prefer your solution.

    Thanks 
  5. MARS-Jainith
    MARS-Jainith avatar
    6 posts
    Member since:
    Nov 2012

    Posted 15 Nov 2013 Link to this post

    Hi
    I get RadDropDownTree selected value for previous selection even i tried below code
    <telerik:RadDropDownTree runat="server" ID="RadDropDownTreeAccounts" Skin="Metro"
                                                Width="250px" DefaultMessage="Choose an account" DefaultValue="0"
                                                DataTextField="AccountName" CheckBoxes="None"    
                                                DataFieldID="AccountNumber" DataValueField="AccountNumber"
                                                DataFieldParentID="DepartmentID" Visible="false"
                                                OnClientEntryAdded="onEntryAdded" OnClientEntryAdding="OnClientEntryAdding1"
                                                ></telerik:RadDropDownTree>
          <script language="javascript" type="text/javascript">
         function onEntryAdded(sender, eventArgs) {
             sender.closeDropDown();
             $(".rddtInner").removeClass("rddtFocused");
         }
         function OnClientEntryAdding1(sender, args) {
             if (sender.get_entries().get_count() > 0) {
                 sender.get_entries().clear();
             }
         }
        </script>                                 

    How to select selected value of Raddropdowntree to only current select value?


  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Nov 2013 Link to this post

    Hi MARS-Jainith,

    Please try the following ASPX to set the current value as the selected value of  RadDropDownTree. If you are setting the CheckBoxex property of RadDropDownTree as None then there is no need of the client side code. By default RadDropDownTree will allow to select a single Item.

    ASPX:
    <telerik:RadDropDownTree ID="RadDropDownTree" runat="server" DataSourceID="SqlDataSource1"
        DataFieldID="id" DataFieldParentID="parentid" DataTextField="text" CheckBoxes="None"
        DefaultMessage="Choose a value" DefaultValue="0" Skin="Metro">
    </telerik:RadDropDownTree>

    Thanks,
    Princy.
  7. MARS-Jainith
    MARS-Jainith avatar
    6 posts
    Member since:
    Nov 2012

    Posted 15 Nov 2013 Link to this post

    Hi Princy,

    Which parameter is used to set current value as the selected value of  RadDropDownTree?
    I used all parameters in your code, but got the same problem.

    Thanks
    Jain
  8. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Nov 2013 Link to this post

    Hi MARS-Jainith,

    The default behavior of RadDropDownTree is that it will allow to select only one item at a time. If the Checkboxes property of the RadDropDown tree is set it as None then the RadDropDownTree will allow to select the current Item only. Please have a look into the sample code snippet to set the current item as selected.

    ASPX:
    <telerik:RadDropDownTree ID="RadDropDownTree" runat="server" DataSourceID="SqlDataSource1"
        DataFieldID="id" DataFieldParentID="parentid" DataTextField="text" DefaultMessage="Choose a value"
        DefaultValue="0" Skin="Metro" CheckBoxes="None">
    </telerik:RadDropDownTree>

    Please provide your full code if it doesn't help.
    Thanks,
    Princy.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017