Hello,
How to set WebdataGrid's default filter to "Contains" when column's Data Type = System.String.
The columns of my WebDataGrid are auto generated form a DataSource (DataTable)
Hi gtarek,
In order to be able to implement this you may need to manually set the types of your non-string fields to something else (if they have not been not automatically configured).
The in order to add a column filter for the string columns you can use something like:
for (int i=0; i < WebDataGrid1.Columns.Count; i++) { if (WebDataGrid1.Columns[i].Type.FullName.ToString().Equals("System.String")) { ColumnFilter filter = new ColumnFilter(); filter.ColumnKey = WebDataGrid1.Columns[i].Key; filter.Condition = new RuleTextNode(TextFilterRules.Contains, ""); WebDataGrid1.Behaviors.Filtering.ColumnFilters.Add(filter); } }
Please let me know if you need more help.
Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://www.infragistics.com/support
Hi Petar,
Thanks for your replay, I have already tried this, but the filter doesn't work , all rows are returned.
If you want to get a "reduced" filter list rather than having a specific filter selected by default, I suggest looking at the solution provided by Tsvetelina in the following thread:
http://forums.infragistics.com/forums/p/54469/281174.aspx
Please contact me if you have any questions.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://www.infragistics.com/support
We need to add : if(!isPostBack)
if(!IsPostBack) for (int i = 0; i < WebDataGrid1.Columns.Count; i++) { if (WebDataGrid1.Columns[i].Type.FullName.ToString().Equals("System.String")) { ColumnFilter filter = new ColumnFilter(); filter.ColumnKey = WebDataGrid1.Columns[i].Key; filter.Condition = new RuleTextNode(TextFilterRules.Contains, ""); WebDataGrid1.Behaviors.Filtering.ColumnFilters.Add(filter); } }
Thanks
Glad that your issue has been resolved. Please do not hesitate to contact me if you have any questions.