Hello Telerik Team,
I can't seem to make multiple checkbox filtering work on a RadComboBox inside a RadGrid using a Filter Template.
I have been working on the examples given on the thread below for several days already..
http://www.telerik.com/forums/how-to-persist-dropdownlist-selected-index-and-value-on-postback-from-radgrid-filtertemplate#GW3MyQLmVEmy8XzsmrHzeQ
Particularly, I used Eyup's sample solution of RadGridFilterComboClientAndServerDataBinding and modified the DataSource to have advance data binding, as I need to populate my RadComboBox in the code behind. But this sample code only supported single item filtering..
So I used the code coming from SearchMultipleValues.aspx and SearchMultipleValues.aspx.cs to implement the multi checkbox filtering. This code can be found on Eyup's post below, inside RadGridFilterMultipleChecked.zip:
http://www.telerik.com/support/code-library/multi-selection-radcombobox-for-filtering-grid#2351833
Please check my combined aspx code and code behind below.
ASPX Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadGridFilterComboClientAndServer.aspx.cs" Inherits="RadGridFilterComboClientAndServer" %><%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI, Version=2012.3.1308.35, PublicKeyToken=121fae78165ba3d4, Culture=neutral" %><%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <script type="text/javascript"> //Put your JavaScript code here. </script> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </asp:ScriptManager> <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0" GridLines="None" Width="800px" OnNeedDataSource="RadGrid1_NeedDataSource" AllowFilteringByColumn="true" OnItemDataBound="RadGrid1_ItemDataBound" OnPreRender="RadGrid1_PreRender" OnItemCommand="RadGrid1_ItemCommand"> <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID"> <Columns> <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" FilterControlAltText="Filter OrderID column" HeaderText="OrderID" ReadOnly="True" SortExpression="OrderID" UniqueName="OrderIDClient"> <FilterTemplate> <telerik:RadComboBox ID="RadComboBoxClientInner" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("OrderIDClient").CurrentFilterValue %>' OnDataBinding="RadComboBoxes_DataBinding" DataTextField="TextFieldName" DataValueField="ValueFieldName" runat="server" OnClientSelectedIndexChanged="CountryIndexChanged"> <Items> <telerik:RadComboBoxItem Text="All" /> </Items> </telerik:RadComboBox> <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server"> <script type="text/javascript"> function CountryIndexChanged(sender, args) { var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>"); tableView.filter("OrderIDClient", args.get_item().get_value(), "EqualTo"); } </script> </telerik:RadScriptBlock> </FilterTemplate> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" FilterControlAltText="Filter OrderID column" HeaderText="OrderID" ReadOnly="True" SortExpression="OrderID" UniqueName="OrderIDServer"> <FilterTemplate> <telerik:RadComboBox ID="RadComboBoxServerInner" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("OrderIDServer").CurrentFilterValue %>' OnDataBinding="RadComboBoxes_DataBinding" DataTextField="TextFieldName" DataValueField="ValueFieldName" OnSelectedIndexChanged="RadComboBoxServerInner_SelectedIndexChanged" runat="server" AutoPostBack="true"> <Items> <telerik:RadComboBoxItem Text="All" /> </Items> </telerik:RadComboBox> </FilterTemplate> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime" FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate" SortExpression="OrderDate" UniqueName="OrderDate"> </telerik:GridDateTimeColumn> <telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal" FilterControlAltText="Filter Freight column" HeaderText="Freight" SortExpression="Freight" UniqueName="Freight"> </telerik:GridNumericColumn> <telerik:GridBoundColumn DataField="ShipName" FilterControlAltText="Filter ShipName column" HeaderText="ShipName" SortExpression="ShipName" UniqueName="ShipName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ShipCountry" FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry" SortExpression="ShipCountry" UniqueName="ShipCountry"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Quantity" FilterControlAltText="Filter Quantity column" HeaderText="Quantity" SortExpression="Quantity" UniqueName="Quantity"> <FilterTemplate> <telerik:RadComboBox ID="RadComboBoxQuantity" DataTextField="Quantity" DataValueField="Quantity" Height="100px" AppendDataBoundItems="true" CheckBoxes="true" runat="server" EmptyMessage="Select Quantity" Skin="Metro" Filter="Contains" OnDataBinding="RadComboBoxQuantity_DataBinding"> </telerik:RadComboBox> <asp:ImageButton ID="ImageButton1" runat="server" AlternateText="Filter" ToolTip="Filter by Quantity" OnClick="ImageButton1_Click" ImageUrl="~/worldSearch.png" /> </FilterTemplate> </telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> </form></body></html>Code Behind:
using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Telerik.Web.UI;public partial class RadGridFilterComboClientAndServer : System.Web.UI.Page{ bool isFiltered = false; protected void Page_Load(object sender, EventArgs e) { } protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { RadGrid1.DataSource = GetGridSource(); } protected void RadComboBoxServerInner_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { GridFilteringItem filterItem = (sender as RadComboBox).NamingContainer as GridFilteringItem; filterItem.OwnerTableView.GetColumn("OrderIDServer").CurrentFilterValue = e.Value; filterItem.FireCommandEvent("Filter", new Pair("EqualTo", "OrderIDServer")); } private DataTable GetGridSource() { DataTable dataTable = new DataTable(); DataColumn column = new DataColumn(); column.DataType = Type.GetType("System.Int32"); column.ColumnName = "OrderID"; dataTable.Columns.Add(column); column = new DataColumn(); column.DataType = Type.GetType("System.DateTime"); column.ColumnName = "OrderDate"; dataTable.Columns.Add(column); column = new DataColumn(); column.DataType = Type.GetType("System.Decimal"); column.ColumnName = "Freight"; dataTable.Columns.Add(column); column = new DataColumn(); column.DataType = Type.GetType("System.String"); column.ColumnName = "ShipName"; dataTable.Columns.Add(column); column = new DataColumn(); column.DataType = Type.GetType("System.String"); column.ColumnName = "ShipCountry"; dataTable.Columns.Add(column); column = new DataColumn(); column.DataType = Type.GetType("System.String"); column.ColumnName = "Quantity"; dataTable.Columns.Add(column); DataColumn[] PrimaryKeyColumns = new DataColumn[1]; PrimaryKeyColumns[0] = dataTable.Columns["OrderID"]; dataTable.PrimaryKey = PrimaryKeyColumns; for (int i = 0; i <= 80; i++) { DataRow row = dataTable.NewRow(); row["OrderID"] = i + 1; row["OrderDate"] = DateTime.Now; row["Freight"] = (i + 1) + (i + 1) * 0.1 + (i + 1) * 0.01; row["ShipName"] = "Name " + (i + 1); row["ShipCountry"] = "Country " + (i + 1); row["Quantity"] = "Quantity " + (i + 1); dataTable.Rows.Add(row); } return dataTable; } protected void RadComboBoxes_DataBinding(object sender, EventArgs e) { RadComboBox combo = sender as RadComboBox; combo.DataSource = Enumerable.Range(1, 6).Select( x => new { ValueFieldName = x, TextFieldName = "ID " + x }); } protected void RadComboBoxQuantity_DataBinding(object sender, EventArgs e) { RadComboBox combo = sender as RadComboBox; combo.DataSource = GetGridSource(); combo.DataTextField = "Quantity"; } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { GridFilteringItem filterItem = (sender as ImageButton).NamingContainer as GridFilteringItem; RadComboBox combo = filterItem.FindControl("RadComboBoxQuantity") as RadComboBox; List<string> expressions = new List<string>(); List<string> quantity = new List<string>(); foreach (RadComboBoxItem item in combo.CheckedItems) { quantity.Add(item.Text); expressions.Add("(it[\"Quantity\"].ToString().Contains(\"" + item.Text + "\"))"); } isFiltered = true; string value = string.Join("OR", expressions.ToArray()); ViewState["QuantityFilterValue"] = string.IsNullOrEmpty(value) ? value : "(" + value + ")"; ViewState["Quantity"] = quantity; } protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.FilterCommandName) { isFiltered = true; } } protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridFilteringItem) { RadComboBox combo = (e.Item as GridFilteringItem).FindControl("RadComboBoxQuantity") as RadComboBox; if (ViewState["Quantity"] != null) { foreach (string quantity in (List<string>)ViewState["Quantity"]) { combo.FindItemByText(quantity).Checked = true; } } } } protected void RadGrid1_PreRender(object sender, System.EventArgs e) { if (isFiltered) { string[] expressions = RadGrid1.MasterTableView.FilterExpression.Split(new string[] { "AND" }, StringSplitOptions.None); List<string> columnExpressions = new List<string>(expressions); foreach (string expression in columnExpressions) { if (expression.Contains("[\"Quantity\"]")) { columnExpressions.Remove(expression); break; } } string finalExpression = string.Join("AND", columnExpressions.ToArray()); string quantityFilterValue = (string)ViewState["QuantityFilterValue"]; if (!string.IsNullOrEmpty(quantityFilterValue)) { if (!string.IsNullOrEmpty(finalExpression)) { finalExpression += " AND "; } finalExpression += quantityFilterValue; } RadGrid1.MasterTableView.FilterExpression = finalExpression; RadGrid1.MasterTableView.Rebind(); } }}
I added a new column, "Quantity", which will be filtered using multi checkbox filtering. This is our focus which is not working.. This column is populated inside the GetGridSource(). Filter values are binded to the RadComboBox using RadComboBoxQuantity_DataBinding event, setting it to the same data source of the RadGrid. (I know I should bind distinct values here, but just for the purpose of an example I haven't updated the code yet.)
Selecting several items from the combobox and clicking ImageButton1, multi checkbox filtering does not work..
Note: I put Filter="Contains" in the RadComboBox property as I read somewhere here and in the documentation that this will enable the textfield in the combo box so the user can type, which I also need.
I am currently stuck using Telerik.Web.UI, Version=2012.3.1308.35. Would anyone know why the multi checkbox filtering does not work?
Any help is appreciated.. Thank you in advance.
I am trying to have the AutoCompleteBox fit in with the other controls on my form. Note that the textbox is not style similarly to the other textboxes. Is there some technique to obtain consistency?
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" Skin="Web20" /><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /><telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" Skin="Web20"></telerik:RadAutoCompleteBox><br /><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br /><asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
The screenshot attached show first without the RadDecorator and then with (note that it does not make it better.

Message: Syntax error URI: http://test/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d3.5.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen%3a0d787d5c-3903-4814-ad72-296cea810318%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2010.2.929.20%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen%3a59f173b0-ff20-435c-8399-1ee5d3741dba%3a16e4e7cd%3a86526ba7%3a874f8ea2%3a11e117d7
This is my code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="captchaTelerik.aspx.vb" Inherits="captchaSound" %> <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <style type="text/css"> .divCaptcha { float: left; height: 220px; width: 433px; background-image: url('pic/captcha_back.png'); background-repeat: no-repeat; padding-top: 1px; } .rcCaptchaAudioLink { margin-left: 20px; font-size: 16px; float: left; color: White; display: block; line-height: 1.5em; background-image: url('pic/audio_but.png'); background-repeat: no-repeat; height: 30px; padding-left: 40px; margin-top: 12px; width: 120px; } .rcCaptchaAudioLink:hover { color: #F0F0F0; } .rcCaptchaImage { float: left; } .qsfPanel { float: right; } .errorMessage { margin-left: 30px; line-height: 20px; } </style> </head> <body> <form id="form1" runat="server"> <div> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" Skin="Hay" /> <div class="divCaptcha"> <table> <tr> <td style="height: 20px;"> <asp:Label ID="lblErrorMessage" runat="server" ForeColor="Red" CssClass="errorMessage"></asp:Label> </td> </tr> <tr> <td style="width: 100%; text-align: center; padding-left: 30px; padding-top: 3px;"> <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ErrorMessage="Page not valid. The code you entered is not valid." ValidationGroup="vgAudio" ValidatedTextBoxID="rcTextBox1" Display="None"> <CaptchaImage EnableCaptchaAudio="true" RenderImageOnly="true" ImageCssClass="rcCaptchaImage" BackgroundColor="#609f0a" TextColor="White" BackgroundNoise="None" /> </telerik:RadCaptcha> </td> </tr> <tr> <td style="padding-left: 100px; padding-top: 10px;"> <br /> <asp:Label ID="rcLabel1" runat="server" AssociatedControlID="rcTextBox1" Text="Type the code from the image:"ForeColor="#005000"></asp:Label> <br /> <asp:TextBox ID="rcTextBox1" runat="server" MaxLength="5" Width="170px"></asp:TextBox> <asp:Button ID="captchaButton" runat="server" ValidationGroup="vgAudio" Text="Submit" OnClick="validateTelerikCaptcha"/> </td> </tr> </table> </div> <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> <script type="text/javascript"> //<![CDATA[ /* function pageLoad() { var captchaTextBox = document.getElementById("<%= rcTextBox1.ClientID %>"); captchaTextBox.setAttribute("autocomplete", "off"); }*/ //]]> </script> </telerik:RadScriptBlock> </div> </form> </body> </html> Thx
So paging was working now it doesn't. Here is the code and grid layout:
GRID
<telerik:RadGrid ID="grdReport" runat="server" AllowPaging="True" AllowSorting="False" ExportSettings-IgnorePaging="true" AutoGenerateColumns="False" PageSize="20" Skin="Office2010Blue" OnPageIndexChanged="grdReport_PageIndexChanged">
<GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
<ExportSettings FileName="TestRejectReport" IgnorePaging="True">
</ExportSettings>
<MasterTableView>
<Columns>
<telerik:GridBoundColumn DataField="Line" FilterControlAltText="Filter Line column" HeaderText="Line" UniqueName="Line">
<HeaderStyle HorizontalAlign="Center" Width="20px" />
<ItemStyle HorizontalAlign="Right" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Process" FilterControlAltText="Filter Process column" HeaderText="Process" UniqueName="Process">
<HeaderStyle HorizontalAlign="Center" Width="50px" />
<ItemStyle HorizontalAlign="Center" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Product" FilterControlAltText="Filter Product column" HeaderText="Product" UniqueName="Product">
<HeaderStyle HorizontalAlign="Center" Width="50px" />
<ItemStyle HorizontalAlign="Center" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Tested" FilterControlAltText="Filter Tested column" HeaderText="Tested" UniqueName="Tested">
<HeaderStyle HorizontalAlign="Center" Width="30px" />
<ItemStyle HorizontalAlign="Right" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Passed" FilterControlAltText="Filter Passed column" HeaderText="Passed" UniqueName="Passed">
<HeaderStyle HorizontalAlign="Center" Width="30px" />
<ItemStyle HorizontalAlign="Right" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Failed" FilterControlAltText="Filter Failed column" HeaderText="Failed" UniqueName="Failed">
<HeaderStyle HorizontalAlign="Center" Width="30px" />
<ItemStyle HorizontalAlign="Right" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Yield" FilterControlAltText="Filter Yield column" HeaderText="Yield" UniqueName="Yield">
<HeaderStyle HorizontalAlign="Center" Width="30px" />
<ItemStyle HorizontalAlign="Right" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Top5" FilterControlAltText="Filter Top5 column" HeaderText="(Count) Top n Rejects" UniqueName="Top5">
<HeaderStyle HorizontalAlign="Center" Width="800px" />
<ItemStyle HorizontalAlign="Left" Wrap="true" />
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
CODE:
I load a datatable (I did see the data in it) and then bind in a button event
grdReport.DataSource = dtReport;
grdReport.DataBind();
Session["Report"] = dtReport;
Session.Timeout = 30;
protected void grdReport_PageIndexChanged(object sender, GridPageChangedEventArgs e)
{
//**********
//pagination
//**********
DataTable dt = (DataTable)Session["Report"];
grdReport.DataSource = dt;
grdReport.Rebind(); // DataBind(); // note I have tried DataBind and Rebind here
}
I get no grid when a page is selected.
Thanks for your help in advance.
Mark
I'm having an issue where on some of the clients when they type in the RadAutoComplete the last character they type isn't registering. I'll attach screen shots from two machines with the same search term and different results. Has anybody else reported this behavior? I'm just loading the search list in code behind it is really straight forward.
<telerik:radautocompletebox runat="server" Style="width: 200px;" id="acbInsured" MaxResultCount="20" DataTextField="CompanyName" DataValueField="ClientKey">
</telerik:radautocompletebox>
public void SetInsuredSearchDatasource(IEnumerable<Contact> searchResults)
{
acbInsured.DataSource = searchResults.ToArray();
acbInsured.DataBind();
}
public override void OnLoad()
{
SetInsuredSearchDatasource(_reportService.GetInsuredNameSearchResults());
...
I'm at a bit of a loss as to why it happens on some but not others (Same browser).
Hello,
i use a split button, which has a RadContextMenu attached to it. Inside the RadContextMenu, there is one RadMenuItem which contains an ItemTemplate with multiple RadCheckBoxes.
How is it possible that the RadCheckBoxes inside the ContentTemplate uses the full available width? So there should be no padding/margin in the ContextMenu and the Checkbox stretches horizontally to use all of the existing space. I uploaded an example of how it looks like right now in the attachments of this post.
Code:
<telerik:RadButton EnableSplitButton="true" ID="btn4" AutoPostBack="true"runat="server" Text="Example Button Text" OnClientClicked="OnClickedRadButton" CommandName="cmdBt4" OnClick="btn4_Click" CausesValidation="true"></telerik:RadButton><telerik:RadContextMenu id="rcmBtn4" runat="server"> <Items> <telerik:RadMenuItem> <ItemTemplate> <p> <telerik:RadCheckBox runat="server" ID="rcb1" CausesValidation="false" Checked="true" Text="als Excel-Datei (.xlsx) exportieren" AutoPostBack="false" /> </p> <p> <telerik:RadCheckBox runat="server" ID="rcb2" CausesValidation="false" Checked="true" Text="Checkbox Text 2" AutoPostBack="false" /> </p> </ItemTemplate> </telerik:RadMenuItem> </Items></telerik:RadContextMenu>