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.
Syncfusion Feedback

Gridgrouping Filter

Thread ID:

Created:

Updated:

Platform:

Replies:

66772 Aug 2,2007 10:11 AM UTC Aug 5,2007 02:15 PM UTC Windows Forms 7
loading
Tags: GridControl
Amol Choudhari
Asked On August 2, 2007 10:11 AM UTC

Hi
I want to filter the gridgrouping on complex filter string like
{( SubDepartment = 'IBO' AND Colour = 'WHITE' AND SellingPrice > 24) OR (Colour = 'BLUE') OR (Country = 'INDIA') }

I am using RecordFilterDescripter. And adding these FilterConditions to RecordFilterDescripter.

Please help how to add logical operator in above example.

Thanks,
Amol choudhari

haneefm [Syncfusion]
Replied On August 3, 2007 03:22 PM UTC

Hi Amoul,

Below is a forum thread that discuss with the similar issue. please try this and let me know if this helps.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=58295

Best regards,
Haneef

Amol Choudhari
Replied On August 4, 2007 12:36 PM UTC

No This is not helpful for me.
Since in that example you are passing condition in string format to RecordFilterDescriptor.

But in my case I am passing FilterCondition in RecordFilterDescriptor.
For Eg.
FilterCondition filterCondition1 = new FilterCondition(Syncfusion.Grouping.FilterCompareOperator.Equals, "IBO");
RecordFilterDescriptor rfd = new RecordFilterDescriptor();
rfd.Name = "SubDepartment";
rfd.Conditions.Add(filterCondition1);
dgRangePlanGrid.TableDescriptor.RecordFilters.Add(rfd);


// dgRangePlanGrid.TableDescriptor.RecordFilters.LogicalOperator = FilterLogicalOperator.And;


RecordFilterDescriptor rfd2 = new RecordFilterDescriptor();
filterCondition1 = new FilterCondition(Syncfusion.Grouping.FilterCompareOperator.Equals, "WHITE");

rfd2.Name = "Colour";
rfd2.Conditions.Add(filterCondition1);
dgRangePlanGrid.TableDescriptor.RecordFilters.Add(rfd2);


//dgRangePlanGrid.TableDescriptor.RecordFilters.LogicalOperator = FilterLogicalOperator.Or;


RecordFilterDescriptor rfd1 = new RecordFilterDescriptor();
filterCondition1 = new FilterCondition(Syncfusion.Grouping.FilterCompareOperator.GreaterThan, "24");
rfd1.Name = "SellingPrice";
rfd1.Conditions.Add(filterCondition1);
dgRangePlanGrid.TableDescriptor.RecordFilters.Add(rfd1);

If I have to Add one more FilterCondition(For eg. Colour = BLUE) in above for ORing it then how should I proceed.

My Whole Condition is:
{(SubDepartment = 'IBO' AND Colour = 'WHITE' AND SellingPrice > 24 ) OR (Colour = 'BLUE')}

Please help !

Amol Choudhari
Replied On August 4, 2007 12:36 PM UTC

No This is not helpful for me.
Since in that example you are passing condition in string format to RecordFilterDescriptor.

But in my case I am passing FilterCondition in RecordFilterDescriptor.
For Eg.
FilterCondition filterCondition1 = new FilterCondition(Syncfusion.Grouping.FilterCompareOperator.Equals, "IBO");
RecordFilterDescriptor rfd = new RecordFilterDescriptor();
rfd.Name = "SubDepartment";
rfd.Conditions.Add(filterCondition1);
dgRangePlanGrid.TableDescriptor.RecordFilters.Add(rfd);


// dgRangePlanGrid.TableDescriptor.RecordFilters.LogicalOperator = FilterLogicalOperator.And;


RecordFilterDescriptor rfd2 = new RecordFilterDescriptor();
filterCondition1 = new FilterCondition(Syncfusion.Grouping.FilterCompareOperator.Equals, "WHITE");

rfd2.Name = "Colour";
rfd2.Conditions.Add(filterCondition1);
dgRangePlanGrid.TableDescriptor.RecordFilters.Add(rfd2);


//dgRangePlanGrid.TableDescriptor.RecordFilters.LogicalOperator = FilterLogicalOperator.Or;


RecordFilterDescriptor rfd1 = new RecordFilterDescriptor();
filterCondition1 = new FilterCondition(Syncfusion.Grouping.FilterCompareOperator.GreaterThan, "24");
rfd1.Name = "SellingPrice";
rfd1.Conditions.Add(filterCondition1);
dgRangePlanGrid.TableDescriptor.RecordFilters.Add(rfd1);

If I have to Add one more FilterCondition(For eg. Colour = BLUE) in above for ORing it then how should I proceed.

My Whole Condition is:
{(SubDepartment = 'IBO' AND Colour = 'WHITE' AND SellingPrice > 24 ) OR (Colour = 'BLUE')}

Please help !

Administrator [Syncfusion]
Replied On August 4, 2007 02:41 PM UTC

You can use parenthesis to produce a compound logical expression that will produce a filter that satifies:
{(SubDepartment = 'IBO' AND Colour = 'WHITE' AND SellingPrice > 24 ) OR (Colour = 'BLUE')}

Try this code:


string filter = "([SubDepartment] LIKE 'IBO' AND [Colour] LIKE 'WHITE' AND [SellingPrice] > 24 ) OR ([Colour] LIKE 'BLUE')";
gridGroupingControl1.TableDescriptor.RecordFilters.Add(filter);


On the string comparisons, I swapped your = to LIKE becuase there is a defect (has been fixed for our next release) where using eual with strings did not work properly, but LIKE does).

Using this compound logical express techique is one way get a combination of AND and OR filters. Another way is to do apply the filter criteria yourself using code in the QueryRecordMeetsFilterCriteria event.

If you add 3 or 4 individual filters to the grid.TableDecriptorRecordFilters, there is no way to AND some of the 4 individual filters and OR others. They are all either ANDed or ORed depending upon the setting of grid.TableDescriptor.RecordFilters.LogicalOperator. So, if you want a compound logical expression used to filter the grid, then you will have to use something like the compound expression technique suggested above, or the QueryRecordMeetsCriteria event.


Amol Choudhari
Replied On August 5, 2007 08:59 AM UTC

hi Burch ,

Thanks, This might help me for current example which I had asked.
But in my design I may get any combination of AND /OR oprators. And depending on parenthesis I have to implement the filterstring.


Actully I am writing Parser which will take input string with "=", AND , OR, (), oprators.
And output will be the string which I am passing to :
gridGroupingControl1.TableDescriptor.RecordFilters.Add("ParsedString");

It may be very descriptive using multiple ANDs and ORs.
So will your solution will help me ???

Can you give me sample example of the QueryRecordMeetsCriteria event.


Again Thanks very much,

Amol Choudhari


Amol Choudhari
Replied On August 5, 2007 09:26 AM UTC

One more problem,

When I tried with
string filter = "([SubDepartment] LIKE 'IBO' AND [Colour] LIKE 'WHITE' AND [SellingPrice] > 24 ) OR ([Colour] LIKE 'BLUE')";
gridGroupingControl1.TableDescriptor.RecordFilters.Add(filter);

I got exception.

Even Simple condition also not works.
like -
string filter = "([SubDepartment] LIKE 'IBO' )";
gridGroupingControl1.TableDescriptor.RecordFilters.Add(filter);

or even,
string filter = "[SellingPrice] > 24 "
does not work.

Please help. ( I am using gridgrouping Control.)

Administrator [Syncfusion]
Replied On August 5, 2007 02:15 PM UTC

Here is a sample that works. Can you upload a sample showing what you are doing that fails?

WindowsApplication79.zip

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.

Warning Icon 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.Close Icon

;