Client side change selected item in radcombobox

7 posts, 0 answers
  1. Phil
    Phil avatar
    7 posts
    Member since:
    Nov 2010

    Posted 24 Nov 2010 Link to this post

    I've been trying to change the selected the item in a radcombox using the following java script code and none of it works:

    var comboBox = <%=rc1.ClientID %>;  
    comboBox.set_Text = "";  
    //document.getElementById("<%=rc1.ClientID %>").value = "";  
      
    var ddlQType = $find("<%=rc1.ClientID%>"); 
    ddlQType._text = "";
    ddlQType.set_selectedItem = "";

    What am I doing wrong?
    Thanks

     

     

     

     

     

     

     

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Nov 2010 Link to this post

    Hello,


    Try accessing the item using 'findItemByText' method and call the select() method to select the item.
     More information on client side methods will be available here:
    Client-Side Basics
    RadComboBox object
    RadComboBoxItem object


    -Shinu.
  3. Phil
    Phil avatar
    7 posts
    Member since:
    Nov 2010

    Posted 03 Jun 2011 Link to this post

    Thanks.  I have a new question.  I have checkbox items in my radcombobox and what I want displayed is the UI is whichever itmes they checked, not the last one they selected.  How would I accomplish this?  Here's my code so far:
    function stopPropagation(e) {
        e.cancelBubble = true;
        if (e.stopPropagation) {
           e.stopPropagation();
        }
      }
      

     

     

    <telerik:radcombobox ID="rcChannels" runat="server" Width="140px" Skin="epsilon" height="180px"

     

     

     

     

    EnableEmbeddedSkins="false" DropDownWidth="200px" HighlightTemplatedItems="True" >

     

     

     

    <ItemTemplate>

     

     

     

    <asp:CheckBox runat="server" ID="CheckBox" onclick="stopPropagation(event);" Text="" /> <%# DataBinder.Eval(Container, "Text") %>

     

     

     

     

    </ItemTemplate>

     

     

     

    </telerik:radcombobox>

     


     

     

     

     

  4. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 07 Jun 2011 Link to this post

    Hello Phil,

    Could you try to explain what exactly you are trying to achieve, since I'm not quite sure what you are aiming for as a functionality?

    Best wishes,
    Dimitar Terziev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. Phil
    Phil avatar
    7 posts
    Member since:
    Nov 2010

    Posted 07 Jun 2011 Link to this post

    I was going down a wrong path.  Thanks anyway.
  6. Anju
    Anju avatar
    2 posts
    Member since:
    May 2013

    Posted 30 May 2013 Link to this post

    Try

    comboBox.set_value("");
  7. Attila Antal
    Admin
    Attila Antal avatar
    341 posts

    Posted 13 Aug Link to this post

    Hi,

    Here is an additional example that may be used:

    Using "previous" and "next" buttons to change/switch the selected items of RadComboBox in client side:

    Sample markup for the buttons and combo.

            <telerik:RadComboBox ID="RadComboBox1" runat="server" RenderMode="Lightweight">
                <Items>
                    <telerik:RadComboBoxItem Text="Item 1" Value="Item1" />
                    <telerik:RadComboBoxItem Text="Item 2" Value="Item2" />
                    <telerik:RadComboBoxItem Text="Item 3" Value="Item3" />
                    <telerik:RadComboBoxItem Text="Item 4" Value="Item4" />
                </Items>
            </telerik:RadComboBox>
            <br />
            <br />
            <telerik:RadButton ID="prevBtn" runat="server" Text="Prev" AutoPostBack="false" OnClientClicked="previous"></telerik:RadButton>
            <telerik:RadButton ID="nextBtn" runat="server" Text="Next" AutoPostBack="false" OnClientClicked="next"></telerik:RadButton>

     

    JavaScript - Click handlers for the buttons.

            <script type="text/javascript">
                function previous(sender, args) {
                    // reference the combobox
                    var combo = $find('<%=RadComboBox1.ClientID %>');
    
                    // do nothing if the current selected index is the first item
                    if (combo.get_selectedIndex() === 0) return;
    
                    // access the next/potential combobox item by index (decrease the current index by one)
                    var previousComboItem = combo.get_items().getItem(combo.get_selectedIndex() - 1);
    
                    // select the item
                    previousComboItem.select();
                }
                function next(sender, args) {
                    // reference the combobox
                    var combo = $find('<%=RadComboBox1.ClientID %>');
    
                    // do nothing if the current selected index is the last item
                    if (combo.get_selectedIndex() === combo.get_items().get_count() - 1) return;
    
                    // access the next/potential combobox item by index (increase the current index by one)
                    var nextComboItem = combo.get_items().getItem(combo.get_selectedIndex() + 1);
    
                    // select the item
                    nextComboItem.select();
                }
            </script>

    Kind  Regards, Attila Antal
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top