Below is code that I have for my custom filter column. Everything works great, however, if I select
"All" from the radcombobox I get "No records to display." I am not sure if it is set up correctly to
either remove the the currentfilterfunction and value or how I set the column to no NoFilter when
"All" is chosen. Any ideas? Below is the code. Thanks is advance.
Joshua
| public class MyCustomFilteringColumn : GridBoundColumn |
| { |
| //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); |
| Telerik.Web.UI.RadComboBox combo = new Telerik.Web.UI.RadComboBox(); |
| combo.ID = ("RadComboBox1" + this.UniqueName); |
| combo.ShowToggleImage = false; |
| combo.Skin = "Office2007";// "Web20"; |
| combo.EnableLoadOnDemand = true; |
| combo.AutoPostBack = true; |
| combo.MarkFirstMatch = true; |
| combo.Height = Unit.Pixel(100); |
| combo.Width = Unit.Pixel(60); |
| combo.ItemsRequested += this.list_ItemsRequested; |
| combo.SelectedIndexChanged += this.list_SelectedIndexChanged; |
| cell.Controls.AddAt(0, combo); |
| 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.Text = this.CurrentFilterValue; |
| } |
| } |
| //RadGrid will call 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.Text; |
| } |
| private void list_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) |
| { |
| ((RadComboBox)o).DataTextField = this.DataField; |
| ((RadComboBox)o).DataValueField = this.DataField; |
| ((RadComboBox)o).DataSourceID = Global.GridDS; |
| ((RadComboBox)o).DataBind(); |
| ((RadComboBox)o).Items.Insert(0, new RadComboBoxItem("All", "")); |
| } |
| private void list_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) |
| { |
| GridFilteringItem filterItem = (GridFilteringItem)((RadComboBox)o).NamingContainer; |
| if ((this.UniqueName == "Index")) |
| { |
| //this is filtering for integer column type |
| filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.UniqueName)); |
| } |
| //filtering for string column type |
| filterItem.FireCommandEvent("Filter", new Pair("Contains", this.UniqueName)); |
| } |
| } |