Hi,
I am using ASP.Net RadControls -Q1 2010 for development.
I am using ColumnFilteringColumn class for filtering.
This working fine without paging, if I select any filtering and click on paging then this displays all record without filtering but just keep selection no actual filtering.
Please suggest any modification for below class for filtering.
public class CustomFilteringColumn : GridTemplateColumn |
{ |
private GridKnownFunction gridKnownFunction; |
/// <summary> |
/// Get Set Filter Function |
/// Predefined filter expression enumaration. Used by CustomFilteringColumn class. |
/// </summary> |
public GridKnownFunction FilterFunction |
{ |
get { return gridKnownFunction; } |
set { gridKnownFunction = value; } |
} |
private String uniqueId; |
public String UniqueId |
{ |
get { return uniqueId; } |
set { uniqueId = value; } |
} |
public CustomFilteringColumn() |
{ |
// |
// TODO: Add constructor logic here |
// |
} |
public DataTable GetDataTable(string strHeaderText) |
{ |
return new DataTable();//external source...here |
} |
protected override void SetupFilterControls(TableCell cell) |
{ |
base.SetupFilterControls(cell); |
Object obj = cell.Controls[0]; |
cell.Controls.RemoveAt(0); |
RadComboBox list = new RadComboBox(); |
list.ID = "list" + this.DataField; |
list.Width = Unit.Percentage(100); |
list.AutoPostBack = true; |
list.ValidationGroup = this.CurrentFilterFunction.ToString(); |
list.SelectedIndexChanged += rcBox_SelectedIndexChanged; |
DataTable table = GetDataTable(this.DataField); |
DataRow row = table.NewRow(); |
row[this.DataField] = "All"; |
table.Rows.InsertAt(row, 0); |
list.DataSource = table; |
cell.Controls.AddAt(0, list); |
cell.Controls.RemoveAt(1); |
list.DataTextField = this.DataField; |
list.DataValueField = this.DataField; |
} |
protected override void SetCurrentFilterValueToControl(TableCell cell) |
{ |
base.SetCurrentFilterValueToControl(cell); |
RadComboBox list = (RadComboBox)cell.Controls[0]; |
list.Items[0].Value = Resources.GeneralMessages.DefaultValue; |
if (this.CurrentFilterValue != string.Empty) |
{ |
list.SelectedValue = this.CurrentFilterValue; |
//GridFilteringItem filterItem = list.NamingContainer as GridFilteringItem; |
//filterItem.FireCommandEvent("Filter", new Pair(gridKnownFunction.ToString(), this.UniqueName)); |
rcBox_SelectedIndexChanged(list, new RadComboBoxSelectedIndexChangedEventArgs("", "", "", "")); |
} |
} |
protected override string GetCurrentFilterValueFromControl(TableCell cell) |
{ |
RadComboBox list = (RadComboBox)cell.Controls[0]; |
if (list.SelectedValue == Resources.GeneralMessages.DefaultValue) |
return String.Empty; |
return list.SelectedValue; |
} |
private void rcBox_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e) |
{ |
GridFilteringItem filterItem = (sender as RadComboBox).NamingContainer as GridFilteringItem; |
filterItem.FireCommandEvent("Filter", new Pair(gridKnownFunction.ToString(), this.UniqueName)); |
} |
} |
<%@ Register TagPrefix="custom" Namespace="FilteringTemplateColumns" %> |
----------------------------- |
<custom:CustomFilteringColumn DataField="strCustomerTypeDefault" SortExpression="strCustomerTypeDefault" |
HeaderText="Customer Type" FilterFunction="Contains" UniqueName="strCustomerTypeDefault"> |
<ItemTemplate> |
<%# Eval("strCustomerTypeDefault")%> |
</ItemTemplate> |
</custom:CustomFilteringColumn> |
Thanks in advance,
Naresh Goradara Thanks in advance,Naresh Goradara