I have been using the Google based filtering example (http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandcombo/defaultcs.aspx?product=grid) to extend the GridDropDownColumn to support a RadComboBox rather than text filter. I am looking for a way to utilize the AutoCompleteSeperator to allow to multiple value selection. So the user could pick 3 items from the list and get a result set of any rows with any one of those columns set. Is this possible? My working code is bellow, it follows the Google example closely.
using System;
using System.Collections.Generic;
using System.Web;
using Telerik.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI;
/// <
summary
>
/// Summary description for DDLColumn
/// </
summary
>
///
namespace DQCT.Controls
{
public class DDLColumn : GridDropDownColumn
{
public DDLColumn()
{
}
//RadGrid will call this method when it initializes the controls inside the filtering item cells
protected override void SetupFilterControls(TableCell cell)
{
base.SetupFilterControls(cell);
cell.Controls.RemoveAt(0);
RadComboBox ddl = new RadComboBox();
ddl.ID = String.Format("_ddl{0}", this.UniqueName);
//ddl.ShowToggleImage = false;
ddl.EnableTextSelection = true;
//ddl.Skin = "Office2007";
ddl.AutoPostBack = true;
//ddl.AutoCompleteSeparator = ";";
ddl.MarkFirstMatch = true;
ddl.Height = Unit.Pixel(100);
ddl.DataTextField = this.ListTextField;
ddl.DataValueField = this.ListValueField;
ddl.DataSourceID = this.DataSourceID;
ddl.SelectedIndexChanged += ddl_SelectedIndexChanged;
cell.Controls.AddAt(0, ddl);
cell.Controls.RemoveAt(1);
}
//RadGrid will cal this method when the value should be set to the filtering input control(s)
protected override void SetCurrentFilterValueToControl(TableCell cell)
{
base.SetCurrentFilterValueToControl(cell);
RadComboBox combo = (RadComboBox)cell.Controls[0];
if ((this.CurrentFilterValue != string.Empty))
{
combo.SelectedValue = this.CurrentFilterValue;
}
}
//RadGrid will cal this method when the filtering value should be extracted from the filtering input control(s)
protected override string GetCurrentFilterValueFromControl(TableCell cell)
{
RadComboBox combo = (RadComboBox)cell.Controls[0];
return combo.SelectedValue;
}
//handler for selected index changed
private void ddl_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
GridFilteringItem filterItem = (GridFilteringItem)((RadComboBox)o).NamingContainer;
filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.UniqueName));
}
}
}