Unplanned
Last Updated: 01 Mar 2024 15:23 by ADMIN
Samuel
Created on: 01 Mar 2024 15:10
Category: GridView
Type: Bug Report
0
RadGridView: Cannot use filter when a column contains empty string and the value (Blanks) at the same time
In a GridView, if there is at the same time in a column empty cells and the value (Blanks), the filter box will fail to open.
1 comment
ADMIN
Nadya | Tech Support Engineer
Posted on: 01 Mar 2024 15:23

Hello, Samuel,

Thank you for reporting this. You can use the following workaround:

public class MyGridViewTextBoxColumn : GridViewTextBoxColumn
{
    protected override GridViewColumnValuesCollection GetDistinctValuesWithFilter()
    {
        int index = this.Index;
        bool containsBlanks = false;
        GridViewColumnValuesCollection distinctValues = new GridViewColumnValuesCollection();

        IEnumerable<GridViewRowInfo> rows = this.OwnerTemplate.Rows;

        foreach (GridViewRowInfo row in rows)
        {
            object cellValue = row.Cells[index].Value;
            if (!containsBlanks)
            {
                containsBlanks = cellValue == null || cellValue == DBNull.Value;
            }
            if (cellValue == "")
            {
                cellValue = "(Blanks)";
            }
            if (!distinctValues.Contains(cellValue))
            {
                distinctValues.Add(cellValue);
            }
        }
        return distinctValues;
    }
}

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.