How to case-insensitive filter comparision
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
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
SIGN IN To post a reply.
2 Replies
AD
Administrator
Syncfusion Team
May 15, 2008 01:39 AM UTC
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
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
SR
Sri Rajan
Syncfusion Team
May 27, 2008 01:23 PM UTC
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.
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.
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
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
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
AD Administrator
- May 14, 2008 09:31 AM UTC
- May 27, 2008 01:23 PM UTC