I have a textbox which is responsible for filtering the xamdatagrid has an attachedproperty to filter the grid.
Here is the code for the TextChanged:
private static void OnFilterTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var dp = d as DataPresenterBase; if (dp.DefaultFieldLayout != null) { dp.DefaultFieldLayout.RecordFilters.Clear(); dp.DefaultFieldLayout.Settings.RecordFiltersLogicalOperator = LogicalOperator.Or; foreach (var field in dp.DefaultFieldLayout.Fields) { var filter = new RecordFilter(); filter.Field = field; filter.Conditions.Add(new ComparisonCondition(ComparisonOperator.Contains, e.NewValue)); dp.DefaultFieldLayout.RecordFilters.Add(filter); } }}
What do I have to do that the filtering is also applied to the all rows (bands)?
I tried already RecordFilterScope="AllRecords" but this wasn't the trick.
sincerely
Hello,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
thank you for your answer. In the meantime I found out that this was the solution.
foreach (var layout in dp.FieldLayouts) layout.RecordFilters.Clear(); foreach (var layout in dp.FieldLayouts) { RecordFilterCollection recordFilterCollection = layout.RecordFilters; recordFilterCollection.Clear(); if (!string.IsNullOrEmpty(e.NewValue as string)) { foreach (var field in layout.Fields) { var filter = new RecordFilter(); filter.Field = field; filter.Conditions.Add(new ComparisonCondition(ComparisonOperator.Contains, e.NewValue)); recordFilterCollection.Add(filter); } } //This one I didn't set before layout.Settings.RecordFiltersLogicalOperator = LogicalOperator.Or; }
Regards and nice weekend.
In that case the results you get, when you type “C”, are expected(following your requirement), because for example, you have column with numeric values (3rd Field from your screenshot), which can never contain characters and this is why all the Records are filtered out.
yes that's right. But didn't find a solution right now.
Regards
Just to clarify that I understand you correct, you want to add a Value in the TextBox and check whether this value is contained in all of the Cells of a Record, and if not, the Record gets Disabled.
Looking forward for your reply.