public FilterCellFactory(C1FlexGridFilter filter, C1FlexGrid flex)
 {
     _flex = flex;
     _gridFilter = filter;
     _baseCellFactory = flex.GetCellFactory();
     _flex.SizeChanged += _flex_ScrollPositionChanging;
     _flex.ScrollPositionChanging += _flex_ScrollPositionChanging;
     Editor = new ColumnFilterEditor();
 }
Esempio n. 2
0
 internal ColumnFilter(C1FlexGridFilter owner, Column column)
 {
     Owner = owner;
     Column = column;
     DataType = column.DataType;
     ConditionFilter = new ConditionFilter(DataType);
     ValueFilter = new ValueFilter(DataType);
     FilterType = FilterType.Automatic;
 }
        private static void BindingColumnsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            try
            {
                var bindingColumns = e.NewValue as ObservableCollection<ColumnConfig>;
                if(bindingColumns != null)
                {
                    var c1FlexGrid = d as C1FlexGrid;
                    if(c1FlexGrid != null)
                    {
                        //List<string> list = new List<string>
                        //{
                        //    "Viewership",
                        //    "Sentiment",
                        //    "AssociationAvg",
                        //    "PreAwareness",
                        //    "PostAwarenessAvg"
                        //};

                        C1FlexGridFilter filter = new C1FlexGridFilter();

                        c1FlexGrid.Columns.Clear();
                        foreach(var bindingColumn in bindingColumns)
                        {
                            var column = new Column
                            {
                                Header = bindingColumn.HeaderName,
                                Binding = new Binding(bindingColumn.ColumnName),
                                Width = new GridLength(bindingColumn.Width),
                                Format = bindingColumn.FormatString,
                                ToolTip = bindingColumn.HeaderDescription,
                                HorizontalAlignment = HorizontalAlignment.Left,
                                HeaderBackground =
                                    new SolidColorBrush(ColorConverter.ConvertFromString(bindingColumn.HeaderColorString) is Color ? (Color)ColorConverter.ConvertFromString(bindingColumn.HeaderColorString) : Colors.White)
                            };
                            c1FlexGrid.Columns.Add(column);
                            //if(list.Contains(bindingColumn.ColumnName))
                            //{
                            //    filter.GetColumnFilter(column);
                            //    var cf13 = filter.GetColumnFilter(column);
                            //    cf13.FilterType = FilterType.Value;

                            //    filter.Apply();
                            //}
                        }

                        #region 设置双列头

                        //var ch = c1FlexGrid.ColumnHeaders;
                        //ch.Rows.Add(new Row());

                        //ch[0, 0] = "省份城市";
                        //ch[1, 0] = "省名";

                        //ch[0, 1] = "省份城市";
                        //ch[1, 1] = "城市";

                        //// allow merging the first fixed row
                        //ch.Rows[0].AllowMerging = true;

                        #endregion

                        //c1FlexGrid.AutoSizeColumns(0, c1FlexGrid.Columns.Count - 1, 0);

                        c1FlexGrid.CellFactory = new FlexGridCellFactory();

                        filter.Owner = c1FlexGrid;
                    }
                }
            }
            catch(Exception ex)
            {
                ShowMessage.Show("列绑定出错");
                LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "Failed to BindingColumnsChanged", ex);
            }
            finally
            {
                if(LogHelper.LogLevel == LogLevelEnum.Debug || LogHelper.LogLevel == LogLevelEnum.Info)
                {
                    LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "BindingColumnsChanged", null);
                }
            }
        }
 public static void SetFlexGridFilter(DependencyObject obj, C1FlexGridFilter value)
 {
     obj.SetValue(C1FlexGridFilterService.FlexGridFilterProperty, value);
 }