【问题标题】:Determine filter status on a xamDataGrid确定 xamDataGrid 上的筛选器状态
【发布时间】:2013-02-13 18:01:49
【问题描述】:

在我正在开发的 WPF 应用程序中,我想以编程方式确定 xamDataGrid 是否配置了任何过滤器。

我已经为 Excel 配置了导出功能,并希望快速检查以确定过滤器是否处于活动状态,如果过滤器处于活动状态,那么我将为用户提供导出过滤行的选项或不是……

我找不到合适的班级成员。

有什么想法吗?

【问题讨论】:

    标签: wpf filter infragistics xamdatagrid


    【解决方案1】:

    找到答案,男生和女生...

        var activeFilterCount = xamDataGrid1.FieldLayouts[0].RecordFilters.Sum(recordFilter => recordFilter.Conditions.Count);
    

    【讨论】:

      【解决方案2】:

      XamDataGrid 可以有多个字段布局(分层结构)。在这种情况下,您需要考虑所有FieldLayouts 而不仅仅是第一个。所以完整的解决方案是:

       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
       }
      

      Filters 存储在 FieldLayout 中是有原因的。

      在早期版本中,它们存储在RecordManger 反对grid。所以这是迭代的完整解决方案 全部FieldLayouts

      点赞:Multiple Layout and Filters can be applied on every Layout/Level

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-05-13
        • 1970-01-01
        • 2013-04-02
        • 1970-01-01
        • 2013-05-23
        • 1970-01-01
        • 1970-01-01
        • 2022-01-20
        相关资源
        最近更新 更多