I have a requirement where a datacolumn needs to have multiple filters applied on particular scenario - if the user types Waiting then all the records that have status of Waiting, DeclinedWaiting, QueuedWaiting must be included. I have FilterRow enabled in my Grid.
Thanks in advance.
Hello Geetha,
Thank you for your post. I have been looking into your requirement and you could apply a filter with ‘Contains’ condition on your ‘Status’ field in your XamDataGrid like e.g.:
FieldLayout fieldLayout = xamDataPresenter1.FieldLayouts[0];
RecordFilter filter = new RecordFilter();
filter.FieldName = "Status";
filter.Conditions.Add(new ComparisonCondition(ComparisonOperator.Contains, "Waiting"));
fieldLayout.RecordFilters.Add(filter);
I am attaching a sample application(DataGridFilteringCondition.zip) that approach.
Let me know, if you need any further assistance on this matter.
Hi Yanko,
Thank you for your prompt answer with an example - much appreciated. My current requirement is that when the user types "Waiting" then all the records that has Waiting, Suspended and Queued to be included and not just the record with "Waiting" status. We do not need filter dropdown.
What I have tried is if the filter matches then added more conditions but it does not work.
if ("Waiting".Contains( filterValue.ToLower())) { filter1.Conditions.Add(new Infragistics.Windows.Controls.ComparisonCondition() { Operator = Infragistics.Windows.Controls.ComparisonOperator.Contains , Value = "Suspended" });}
Thank you for your reply. I have been looking into it and it seems that you just need to be able to type in the filter box without having option to choose an item from the filter dropdown. You could achive this functionality by defining the field and setting its ‘FilterOperatorDefaultValue’ to “Contains” and ‘FilterOperatorUIType’ to “TextBox” like:
<igDP:Field Name="Status">
<igDP:Field.Settings>
<igDP:FieldSettings
FilterOperatorDefaultValue="Contains"
FilterOperandUIType="TextBox"/>
</igDP:Field.Settings>
</igDP:Field>
I am attaching a modified version of my sample application(DataGridFilteringIssue2.zip).
That's what I have at the moment, but how would I add another filter? For example user types "Waiting" - by default all the status of Waiting will be selected and the rest ignored. What I want is if the user types "Waiting" then records which have "Waiting", "Suspended", "Queued" to be shown and the rest ignored. In essence I want to to include additional OR filters ie in sql Status = 'Waiting' OR Status = 'Suspended' OR Status = 'Queued'. Thanks
Thank you for your reply. I have been looking into your requirement and you could handle the ‘RecordFilterChanging’ event in order to add the additional conditions like:
private void xamDataPresenter1_RecordFilterChanging(object sender, Infragistics.Windows.DataPresenter.Events.RecordFilterChangingEventArgs e)
{
if (e.NewRecordFilter.Conditions.Count != 0 && (e.NewRecordFilter.Conditions[0] as ComparisonCondition).Value.ToString().Contains("Waiting") || e.NewRecordFilter.Conditions.Count != 0 && (e.NewRecordFilter.Conditions[0] as ComparisonCondition).Value.ToString().Contains("waiting"))
e.NewRecordFilter.Conditions.LogicalOperator = LogicalOperator.Or;
e.NewRecordFilter.Conditions.Add(new ComparisonCondition(ComparisonOperator.Contains, "Suspended"));
e.NewRecordFilter.Conditions.Add(new ComparisonCondition(ComparisonOperator.Contains, "Queued"));
}