Found the answer guys n girls...
var activeFilterCount = xamDataGrid1.FieldLayouts[0].RecordFilters.Sum(recordFilter => recordFilter.Conditions.Count);
سؤال
In a WPF app I'm developing I'd like to programmatically determine if a xamDataGrid has any filters configured or not.
I've configured an export function to Excel and would like to do a quick check to determine if a filter is active or not, if a filter is active then I'll present the user with the option to export filtered rows or not...
I can't find any suitable class members.
Any ideas?
المحلول
Found the answer guys n girls...
var activeFilterCount = xamDataGrid1.FieldLayouts[0].RecordFilters.Sum(recordFilter => recordFilter.Conditions.Count);
نصائح أخرى
A XamDataGrid
can have more than one field layout (hierarchical structure). In that case you need to consider all FieldLayouts
not just the first one. So the complete solution is:
public bool AreFiltersActive()
{
int activeFilterCount = 0;
foreach (FieldLayout f in xamDataGrid.FieldLayouts)
{
activeFilterCount+= f.RecordFilters.Sum(recordFilter => recordFilter.Conditions.Count);
//retrieve filter count per layout
}
return activeFilterCount > 0;
//If any fieldlayout has any filter active then the sum will be more than 0
}
There is a reason why
Filters
are stored perFieldLayout
inXamDataGrid
.In the earlier version they are stored in
RecordManger
against thegrid
. So it's the complete solution to iterate the allFieldLayouts
.
Like Below Grid:Multiple Layout and Filters can be applied on every Layout/Level