We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

removing "Custom" and "Empty" filter options

Hi Support
i am using GridGroupingControl version 11.3045.0.30
i'm trying to remove the empty and custom filter options, in your documentation i found that i need to use the FilterRowOptions.AllowEmptyFilter
and FilterRowOptions.AllowCustomFilter properties, however, these properties are not available

Error 19 'Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor' does not contain a definition for 'FilterRowOptions' and no extension method 'FilterRowOptions' accepting a first argument of type 'Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor' could be found (are you missing a using directive or an assembly reference?)

i'm assuming that this is because i'm using a very old version of the control
given that i cant upgrade, how can i remove these filter options ?

thanks
Dado







1 Reply

Arulraj A November 13, 2018 05:38 AM UTC

Hi Dado, 

Thanks for contacting Syncfusion support. 

To remove the Custom and Empty options from filter drop down list in Syncfusion product version 11.3.0.30, you could implement a custom filter bar cell that derives the cell model/cell renderer from the GridTableFilterBarCellModel/GridTableFilterBarCellRenderer
The GridTableFilterBarCellModel.FillWithChoices method is overridden to remove the string Custom from the list. Please refer the follwoing code example and the KB link, 
C# 
this.gridGroupingControl1.TableModel.CellModels.Add("GridTableFilterBarCell", new GridTableFilterBarCellModel1(this.gridGroupingControl1.TableModel)); 
//Assigns the FilterBarCelltype as GridTableFilterBarCell 
this.gridGroupingControl1.TableDescriptor.Appearance.FilterBarCell.CellType = "GridTableFilterBarCell"; 
 
public class GridTableFilterBarCellModel1 : GridTableFilterBarCellModel 
{ 
    public GridTableFilterBarCellModel1(Syncfusion.Windows.Forms.Grid.GridModel gm) 
        : base(gm) 
    { 
    } 
 
    //Overrides FillWithChoices to remove 'Custom' option from the list. 
    public override void FillWithChoices(ListBox listBox, GridStyleInfo style, out bool exclusive) 
    { 
        exclusive = true; 
        GridTableCellStyleInfo tableStyleInfo = (GridTableCellStyleInfo)style; 
        object[] items = (object[])GetFilterBarChoices(tableStyleInfo.TableCellIdentity); 
        listBox.Items.Clear(); 
        if (items != null) 
        { 
            listBox.Items.Add(SelectAllText); 
            foreach (object item in items) 
            { 
                if (item != null && item != DBNull.Value) 
                    listBox.Items.Add(style.GetFormattedText(item)); 
            } 
        } 
    } 
 
    //Customizes the 'Select' method to hide the Custom option. 
    public void Select_WithoutCustom(GridTableCellStyleInfoIdentity tableCellIdentity, int index) 
    { 
        if (index >= 0) 
        { 
            if (index == 0) 
            { 
                ResetFilterBar(tableCellIdentity); 
            } 
            else 
            { 
                SelectItem(tableCellIdentity, index - 1); 
            } 
        } 
    } 
    public override GridCellRendererBase CreateRenderer(GridControlBase control) 
    { 
       return new Cellrenderer(control, this); 
    } 
 
} 
public class Cellrenderer : GridTableFilterBarCellRenderer 
{ 
    public Cellrenderer(GridControlBase grid, GridCellModelBase cellModel) 
        : base(grid, cellModel) 
    { 
    } 
    public new GridTableFilterBarCellModel1 Model 
    { 
        get 
        { 
            return (GridTableFilterBarCellModel1)base.Model; 
        } 
    } 
 
    //Overridse ListBoxMouseUP method to call Customized Select method instead of the usual 'Select' method. 
    protected override void ListBoxMouseUp(object sender, MouseEventArgs e) 
    { 
            
        CurrentCell.CloseDropDown(PopupCloseType.Done); 
        GridTableCellStyleInfo tableStyleInfo = (GridTableCellStyleInfo)this.StyleInfo; 
        GridTableCellStyleInfoIdentity tableCellIdentity = tableStyleInfo.TableCellIdentity; 
        Model.Select_WithoutCustom(tableCellIdentity, this.ListBoxPart.SelectedIndex); 
        SetTextBoxText(GetFilterBarText(StyleInfo), false);// don't call base class - ignore. 
        String _FilterBarValue = this.ListBoxPart.SelectedItem.ToString(); 
        GridTableControl _grid = Grid as GridTableControl; 
        int _filed = _grid.TableDescriptor.ColIndexToField(ColIndex); 
        string _columnName = _grid.TableDescriptor.Columns[_filed].Name; 
        _grid.TableDescriptor.RecordFilters.Remove(_columnName); 
        if (_FilterBarValue != "(All)") 
            _grid.TableDescriptor.RecordFilters.Add(_columnName, FilterCompareOperator.Equals, this.ListBoxPart.SelectedItem); 
 
    } 
} 
 
Please refer the following KB link to remove the Custom option alone from filter drop down list, 
Let us know whether this helps also if you need any further assistance on this. 

Arulraj A 

Loader.
Live Chat Icon For mobile
Up arrow icon