Set Selected Text in RadDropDownTree JavaScript

3 posts, 0 answers
  1. Vijay
    Vijay avatar
    4 posts
    Member since:
    Sep 2014

    Posted 29 Sep 2014 Link to this post

    Hi All,

    My question for client side code only using JavaScript.
    I have a RadDropDownTree in my Form. In that DropDown I have some some data.
    Suppose.
    Central
        Middle Central
                Chicago
        Texoma
    ..
    .
    .
    above mention is same data.

    Now What I want is when User Select Chicago then Select text in client area of that dropdown should be anything like 'ABCD' or anything. I just want to set the
    Selected text of that DropDownTree. I tried below mention code but is not working, In my RadDropDownTree, it still showing emptymessage.

    var combo = $find("<%= RadDropDownLocations.ClientID %>");
    combo._selectedText = "Davolio" + ";" + "Leverling";

    Can someone guide me how can I set the text in DropDownTree
     Let me know in case of any more information

    Vijay
  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 02 Oct 2014 Link to this post

    Hi Vijay,

    Try to handle the OnClientEntryAdded event: 

    <telerik:RadDropDownTree runat="server" ID="ddt" OnClientEntryAdded="OnClientEntryAdded">
    </telerik:RadDropDownTree>
     
    <script>
     
        function OnClientEntryAdded(sender, args) {
            setTimeout(function () {
                $('.rddtFakeInput').text('ABCD');
            }, 10);
        }
     
    </script>


    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. SALVATORE
    SALVATORE avatar
    4 posts
    Member since:
    May 2016

    Posted 10 hours ago in reply to Hristo Valyavicharski Link to this post

    Hi.

    I have my RadDropDownTree in gridview (one for row): how can find it only one in that row?

    My problem is bigger:

    I need to let choose only one item for each year group in my RadDropDownTree and I want to do this client side.

    I have created this javascript code and do it well, but I do not know how refresh SelectedValue (rddtFakeInput) and his Tooltip how you can see in attached picture.

            function OnClientEntryAdded(sender, args) {
                if (sender.get_entries().get_count() > 1) {
                    var tree = sender.get_embeddedTree();
                    tree.trackChanges();
                    var valueSelected = args.get_entry().get_value();
                    for (i = 0; i < sender.get_entries().get_count() ; i++) {
                        //Check same root to have just one selected for year
                        var valueOther = sender.get_entries().getEntry(i).get_value();
                        if (valueOther.toString().substr(0, 6) == valueSelected.toString().substr(0, 6) &&
                            valueOther != valueSelected) {
                            //alert("founded same year");

                            //Uncheck the other

                            var nodeOther = tree.findNodeByValue(valueOther);
                            nodeOther.uncheck();
                        }
                    }                
                    tree.commitChanges();
                }
            }
    <telerik:RadDropDownTree RenderMode="Lightweight" ID="ddtHvrVolume" runat="server" OnDataBound="ddt_DataBound" OnNodeDataBound="ddt_NodeDataBound" DefaultMessage="Please select volumes for each year..." CheckBoxes="SingleCheck" DataFieldID="ID" DataFieldParentID="ParentID" DataTextField="Text" ButtonSettings-ShowClear="False" DropDownSettings-Width="400px" Width="400px" OnClientEntryAdding="OnClientEntryAdding" OnClientEntryAdded="OnClientEntryAdded" DataValueField="Value" CheckNodeOnClick="True">
        <ButtonSettings ShowCheckAll="false" ShowClear="true" />
        <Localization Clear="Clear All" />
    </telerik:RadDropDownTree>

    Thanks in advance,

    Francesco.

Back to Top