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

Selecting one single node

6 Answers 418 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
César
Top achievements
Rank 1
César asked on 06 Nov 2013, 11:15 AM
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

6 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 07 Nov 2013, 06:21 AM
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.
0
César
Top achievements
Rank 1
answered on 07 Nov 2013, 09:05 AM
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 
0
MARS-Jainith
Top achievements
Rank 1
answered on 15 Nov 2013, 10:37 AM
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?


0
Princy
Top achievements
Rank 2
answered on 15 Nov 2013, 12:01 PM
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.
0
MARS-Jainith
Top achievements
Rank 1
answered on 15 Nov 2013, 12:08 PM
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
0
Princy
Top achievements
Rank 2
answered on 20 Nov 2013, 08:21 AM
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.
Tags
DropDownTree
Asked by
César
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
César
Top achievements
Rank 1
MARS-Jainith
Top achievements
Rank 1
Share this question
or