We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridGroupingControl - Custom filters with logical expressions on multiple columns

Thread ID:

Created:

Updated:

Platform:

Replies:

102268 Jan 16,2012 05:15 AM Jan 20,2012 05:52 AM ASP.NET Web Forms (Classic) 2
loading
Tags: GridGroupingControl
Vijay Jayaraj
Asked On January 16, 2012 05:15 AM


Hi,

I am using GridGroupingControl(asp.net) , I would like to have custom(record) filters on multiple columns with [OR] conditions. Currently the Record filters are working like [AND] condition on multiple columns. Below query is my requirement from coding.

Query - 1:

Get all the records where the 'user1' is present in any of the columns like column1 or column2 or column3.

Query - 2:

Get all the records within date range(start date to end date),
applying expressions to filters.

Also Please suggest the userguide for gridgroupingcontrol.


Sridhar N [Syncfusion]
Replied On January 20, 2012 05:52 AM

Hi Vijay,

Thanks for your patience.

Query #1 "Get all the records where the 'user1' is present in any of the columns like column1 or column2 or column3."

Your requirement can be achieved by adding recordfilters with expertssion. Please refer the below code snippet.

[Codebehind - C#]

void UserFilter_Click(object sender, EventArgs e)
{
this.GridGroupingControl1.TableDescriptor.RecordFilters.Clear();
RecordFilterDescriptor rfd = new RecordFilterDescriptor();
StringBuilder sb = new StringBuilder();
foreach (GridVisibleColumnDescriptor gcd in this.GridGroupingControl1.TableDescriptor.VisibleColumns)
{
sb.AppendFormat("[{0}] like '*{1}*' OR ", gcd.Name, "User1");
}
//'remove last ' OR '
sb.Remove(sb.Length - 4, 4);
rfd.Expression = sb.ToString();
this.GridGroupingControl1.TableDescriptor.RecordFilters.Add(rfd);
this.GridGroupingControl1.DataBind();
}


Query #2 "Get all the records within date range(start date to end date),applying expressions to filters."

Your requiement can be achieved by using logical operator. Please refer the below code snippet.

[Codebehind - C#]

void DateFilter_Click(object sender, EventArgs e)
{
this.GridGroupingControl1.TableDescriptor.RecordFilters.Clear();
GridRecordFilterDescriptor filter2 = new GridRecordFilterDescriptor();
filter2.Name = "Dates";
filter2.LogicalOperator = FilterLogicalOperator.And;
filter2.Conditions.Add(Syncfusion.Grouping.FilterCompareOperator.GreaterThan, "3/24/2005");
filter2.Conditions.Add(Syncfusion.Grouping.FilterCompareOperator.LessThan, "5/10/2005");
this.GridGroupingControl1.TableDescriptor.GridRecordFilters.Add(filter2);
}


For your convenience, we have created sample and the same can be downloaded from the following link.

Custom Filter-1812399385.zip

Please let me know if you have any other questions or concerns.

Regards,
Sridhar.N


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;