Hi,
I'm trying to use jQuery to set a selected item in a RadComboBox. This is my HTML:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="EBuild.PWMS.UI.Pages.TestPage" %>
<%@ Register tagprefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<table>
<tr>
<td>Buyer: </td>
<td>
<telerik:RadComboBox ID="RadComboBoxBuyers"
DataValueField="Id" DataTextField="PickerName"
DataSourceID="SqlDataSource1"
EnableAutomaticLoadOnDemand="true" ShowMoreResultsBox="true"
EnableVirtualScrolling="true" ItemsPerRequest="10"
runat="server">
</telerik:RadComboBox>
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource1"
ConnectionString="<%$ ConnectionStrings:APPDB %>"
ProviderName="System.Data.SqlClient"
SelectCommand="usp_GetUsersBuyers"
SelectCommandType="StoredProcedure"
runat="server">
<SelectParameters>
<asp:Parameter Name="IsSearch" Type="Boolean" DefaultValue="True" />
</SelectParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
The problem is I'm not able to get a reference to the ComboBox. I searched the forum and found a bunch of code snippets but none of them works. This is what I tried:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
$(document).ready(function () {
el = $find("RadComboBoxBuyers"); // returns null
el = $("form").find("[id='RadComboBoxBuyers']"); // el.findItemByValue is undefined
el = $telerik.$("#RadComboBoxBuyers"); // el.findItemByValue is undefined
});
</script>
</telerik:RadCodeBlock>
I have hard-coded the name of the control to "RadComboBoxBuyers" in the above code because I know that it is the correct ClientID.
Any suggestions?
Thanks,
Leszek