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.

How to case-insensitive filter comparision

Thread ID:

Created:

Updated:

Platform:

Replies:

73663 May 14,2008 05:31 AM May 27,2008 09:23 AM Windows Forms 2
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 14, 2008 05:31 AM

Hi,

How do I do a case insensitive filter comparision. I have regex expression that i pass to the Filter Condition

var recordFilterDescriptor = new RecordFilterDescriptor(columnName, new FilterCondition(FilterCompareOperator.Match, expression));

How do i make this comparision a case in-sensitive?

Thanks,
Rohit


Administrator [Syncfusion]
Replied On May 14, 2008 09:39 PM

Hi Guys,

Appreciate if you could comment on this?

Cheers

>Hi,

How do I do a case insensitive filter comparision. I have regex expression that i pass to the Filter Condition

var recordFilterDescriptor = new RecordFilterDescriptor(columnName, new FilterCondition(FilterCompareOperator.Match, expression));

How do i make this comparision a case in-sensitive?

Thanks,
Rohit




Sri Rajan [Syncfusion]
Replied On May 27, 2008 09:23 AM

Hi Rohit,

Thank you for your patience.

There are two options available to perform the case insensitive filter.

Option 1:

You need to include vertical bar inside the comparevalue argument of filter.Conditions.Add method, to perform Case Insensitive filter. Here Vertical bar specifies alternative. (ie., either capital or small letter). Suppose if you want to perform case insentive filter for a string "babu", then you need to specify the comparevalue as "(B|b)(A|a)(B|b)(U|u)".Please refer the below code for more details.


RecordFilterDescriptor filter = new RecordFilterDescriptor();
filter.Name = "Name";
filter.LogicalOperator = FilterLogicalOperator.Or;
filter.Conditions.Add(FilterCompareOperator.Match, @"(B|b)(A|a)(B|b)(U|u)");
this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(filter);


Option 2:
You need to call QueryRecordMeetsFilterCriteria event inside the button click event where the filter is applied, to perform the case insensitive filter. Here Case Insensitive comparision is performed inside the QueryRecordMeetsFilterCriteria event. If condition is satisfied then you need to set e.Result as true, otherwise you need to set the e.Result as false. Please refer the below code snippet for more details.

void gridGroupingControl1_QueryRecordMeetsFilterCriteria(object sender, QueryRecordMeetsFilterCriteriaEventArgs e)
{
Object obj = e.Record.GetValue("Name");
if (obj.ToString().ToLower() == "babu")
{
e.Result = true;
Console.WriteLine("Rec:"+obj.ToString());
}
else
{
e.Result = false;
}
e.Handled = true;
}

private void buttonAdv1_Click(object sender, EventArgs e)
{
RecordFilterDescriptor filter = new RecordFilterDescriptor();
filter.Name = "Name";
filter.LogicalOperator = FilterLogicalOperator.Or;
filter.Conditions.Add(FilterCompareOperator.Match, @"babu");
this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(filter);
this.gridGroupingControl1.QueryRecordMeetsFilterCriteria += new QueryRecordMeetsFilterCriteriaEventHandler(gridGroupingControl1_QueryRecordMeetsFilterCriteria);
}


QueryRecordMeetsFilterCriteria - Occurs when a record is checked whether it meets filter criteria and should appear visible in the table's DisplayElements.

Here is the minimal sample which implements this task.
http://websamples.syncfusion.com/samples/grid.windows/F73663/main.htm

Please let me know if this helps.

Best Regards,
Srirajan


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.

;