Unplanned
Last Updated: 29 Mar 2019 13:48 by ADMIN
erwin
Created on: 28 Mar 2019 07:57
Category: GridView
Type: Feature Request
3
RadGridView: filter grid for empty strings via the user interface (traditional filters)

How can I enter the Value "" (empty string) in the traditional filter system (not Excel like filter).

The grid does not seem to accept an empty string as an argument to "Equals" through the UI.

Ideally I would like to extend the standard filter menu in traditional filtering (and the filter operator drop down in custom filtering dialog) to contain operators "Is Empty" "Is Not Empty" and "Is Null Or Empty", "Is Not Null And Not Empty"

Regards

Erwin

3 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 29 Mar 2019 13:48
Hello, Erwin,  

Indeed, this seems to be a reasonable request and we will consider extending the basic filtering functionality.

I have logged it in our feedback portal by making this thread public. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item

I have also updated your Telerik points.


Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
erwin
Posted on: 29 Mar 2019 13:25

Hi Dess,

Thanks for your suggestion. I'm a bit reluctant to implement basic required functionality such filtering for empty cells that are not null by myself.  Extending the Menu as you suggested would lead to inconsistencies in the Custom Filter Dialog I guess.

My suggestion would be that Telerik implement the missing Filters such as Empty, Not Empty to be consistently available in the UI or at least allow to somehow enter an "Equals" condition to an empty string in the custom filter dialog, so that the user could construct a condition like "is null or empty".

Regards

Erwin

 

 

 

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 29 Mar 2019 12:46
Hello, Erwin,  

The basic filtering functionality allows you to filter the null values by selecting the IsNull option from the context menu. As to the empty values, the Excel-like filtering gives you this opportunity. An alternative solution that I can suggest is to use the custom filtering approach that allows you to implement any functionality that you need when filtering data. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/filtering/custom-filtering

However, you can add a custom menu item "IsEmpty" and apply the desired FilterDescriptor. A sample approach is demonstrated in the following code snippet. Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best: 

public RadForm1()
{
    InitializeComponent();
 
    this.radGridView1.Columns.Add("Number");
    this.radGridView1.Columns.Add("TextColumn");
    this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
    this.radGridView1.EnableFiltering = true;
    this.radGridView1.ShowHeaderCellButtons = true;
     
    this.radGridView1.Rows.Add(1, "");
    this.radGridView1.Rows.Add(2, " ");
    this.radGridView1.Rows.Add(3, null);
    this.radGridView1.Rows.Add(4, "test");
 
    this.radGridView1.ContextMenuOpening += radGridView1_ContextMenuOpening;
}
 
private void radGridView1_ContextMenuOpening(object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e)
{
    GridFilterCellElement filterCell = e.ContextMenuProvider as GridFilterCellElement;
    if (filterCell != null && filterCell.ColumnInfo is GridViewTextBoxColumn)
    {
        RadMenuItem emptyItem = new RadMenuItem("IsEmpty");
        emptyItem.Tag = filterCell.ColumnInfo.Name;
        emptyItem.Click += emptyItem_Click;
        e.ContextMenu.Items.Add(emptyItem);
    }
}
 
private void emptyItem_Click(object sender, EventArgs e)
{
    RadMenuItem item = sender as RadMenuItem;
    string propertyName = item.Tag + "";
      
    FilterDescriptor fd = new FilterDescriptor();
    fd.PropertyName = propertyName;
    fd.Operator = FilterOperator.IsEqualTo;
    fd.IsFilterEditor = true;
    fd.Value = "";
    this.radGridView1.FilterDescriptors.Add(fd);
}

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.