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

Client side change selected item in radcombobox

6 Answers 1056 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 24 Nov 2010, 04:16 PM

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

 

 

 

 

 

 

 

 

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Nov 2010, 07:46 AM
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.
0
Phil
Top achievements
Rank 1
answered on 03 Jun 2011, 03:15 PM
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>

 


 

 

 

 

0
Dimitar Terziev
Telerik team
answered on 07 Jun 2011, 02:20 PM
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.

0
Phil
Top achievements
Rank 1
answered on 07 Jun 2011, 02:23 PM
I was going down a wrong path.  Thanks anyway.
0
Anju
Top achievements
Rank 1
answered on 30 May 2013, 12:12 PM
Try

comboBox.set_value("");
0
Attila Antal
Telerik team
answered on 13 Aug 2019, 09:27 AM

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.
Tags
ComboBox
Asked by
Phil
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Phil
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Anju
Top achievements
Rank 1
Attila Antal
Telerik team
Share this question
or