I have placed my radGrid inside a Radcombobox but I try to open a radcombobox by calling OnClientDropDownOpening="OnClientDropDownOpening" using ajax request it gets closed automatically.
function OnClientDropDownOpening(sender, args) {
var comboText = sender.get_text();
if (comboText.length > 2) {
$find("<%= rapJob.ClientID %>").ajaxRequest("LoadFilteredData," + comboText);
}
else {
args.set_cancel(true);
}
}
Protected Sub rapJob_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
Dim rgJob As RadGrid = TryCast(rcbJob.Items(0).FindControl("rgJob"), RadGrid)
If e.Argument.IndexOf("LoadFilteredData") <> -1 Then
rgJob.Rebind()
End If
End Sub
Protected Sub rgJob_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
Dim rgJob As Telerik.Web.UI.RadGrid = source
Dim IJobs = (From Jobs In dbContext.FF_Jobs Where Jobs.IsCreated = True And Jobs.IsCancelled = False And Jobs.IsTemplate = False
Select Jobs).ToList
rgJob.DataSource = IJobs
End Sub
function OnClientDropDownOpening(sender, args) {
var comboText = sender.get_text();
if (comboText.length > 2) {
$find("<%= rapJob.ClientID %>").ajaxRequest("LoadFilteredData," + comboText);
}
else {
args.set_cancel(true);
}
}
Protected Sub rapJob_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
Dim rgJob As RadGrid = TryCast(rcbJob.Items(0).FindControl("rgJob"), RadGrid)
If e.Argument.IndexOf("LoadFilteredData") <> -1 Then
rgJob.Rebind()
End If
End Sub
Protected Sub rgJob_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
Dim rgJob As Telerik.Web.UI.RadGrid = source
Dim IJobs = (From Jobs In dbContext.FF_Jobs Where Jobs.IsCreated = True And Jobs.IsCancelled = False And Jobs.IsTemplate = False
Select Jobs).ToList
rgJob.DataSource = IJobs
End Sub
<telerik:RadAjaxPanel ID="rapJob" RequestQueueSize="5" runat="server" Width="100%" OnAjaxRequest="rapJob_AjaxRequest" EnableOutsideScripts="True" HorizontalAlign="NotSet" ScrollBars="None" LoadingPanelID="alpJob"> <telerik:RadComboBox ID="rcbJob" EmptyMessage="- please select job -" runat="server" OnClientDropDownOpening="OnClientDropDownOpening" MarkFirstMatch="True" Width="300px" Skin="Vista" AutoPostBack="True" AutoCompleteSeparator="true" Filter="Contains" AllowCustomText="true"> <ItemTemplate> <div> <telerik:RadGrid ID="rgJob" runat="server" Width="95%" Skin="Vista" AutoGenerateColumns="False" AllowSorting="True" AllowMultiRowSelection="False" OnNeedDataSource="rgJob_NeedDataSource" AllowPaging="True" GridLines="Both" ExpandAnimation-Type="None" CollapseAnimation-Type="None"> <PagerStyle Mode="NumericPages"></PagerStyle> <MasterTableView Width="100%" DataKeyNames="ID,JobName" Name="rgJob" CommandItemDisplay="None" NoMasterRecordsText="" > <Columns> <telerik:GridBoundColumn SortExpression="ID" HeaderText="ID" HeaderButtonType="TextButton" DataField="ID" UniqueName="ID" ReadOnly="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn SortExpression="JobName" HeaderText="Job Name" HeaderButtonType="TextButton" DataField="JobName" UniqueName="JobName"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings EnableRowHoverStyle="true"> <Selecting AllowRowSelect="true" /> <Scrolling AllowScroll="true" UseStaticHeaders="true" /> </ClientSettings> </telerik:RadGrid> </div> </ItemTemplate> <Items> <telerik:RadComboBoxItem runat="server" Text=" "></telerik:RadComboBoxItem> </Items> </telerik:RadComboBox> </telerik:RadAjaxPanel>