1. 程式人生 > >WPF DevExpress grid 設定自定義篩選欄的條件為包含關係

WPF DevExpress grid 設定自定義篩選欄的條件為包含關係

WPF DevExpress grid 設定自定義篩選欄的條件為包含關係
根據 DevExpress.Xpf.Grid改造
來源:CSDN 
原文:https://blog.csdn.net/alisa525/article/details/41910443

DevExpress.Xpf.Grid:
 foreach (DevExpress.Xpf.Grid.GridColumn item in this.gridSource.Columns)
            {
                item.AutoFilterCondition = DevExpress.Xpf.Grid.AutoFilterCondition.Contains;
            }
過濾器觸發事件;
 void gridSource_FilterChanged(object sender, RoutedEventArgs e)
        {
            var gridcontrol = sender as DevExpress.Xpf.Grid.GridControl;
            var str = gridcontrol.FilterString;
            string filter = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetOracleWhere(gridcontrol.FilterCriteria); //將 篩選欄 條件轉換成 oracle語句
            if (filterString == filter) return;
            else filterString = filter;
            filterString = filterString.Replace("TBBH", "d.TBBH");   //簡單解決
            InitSource(queryOrg, queryFilter, "");
        }

DevExpress.XtraGrid:
 gridView1.OptionsView.ShowAutoFilterRow = true; //顯示篩選行
gridView1.OptionsCustomization.AllowFilter = true;                      //是否允許過濾
gridView1.IndicatorWidth = 40;                       //行標題高度
  gridView1.OptionsView.ShowIndicator = true;          // 顯示行標題
                    foreach (DevExpress.XtraGrid.Columns.GridColumn item in gridView1.Columns)
                    {
                        item.OptionsFilter.AutoFilterCondition = DevExpress.XtraGrid.Columns.AutoFilterCondition.Contains;   //篩選條件設定為包含
                    }

private void gridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            string filter = gridView1.ActiveFilterString;
        }