Completed
Last Updated: 26 Jan 2015 14:01 by ADMIN
ADMIN
Dimitar
Created on: 09 Dec 2014 09:01
Category: GridView
Type: Bug Report
0
FIX. RadGridView - CheckBoxColumn - when the data source contains null values and the header checkbox is shown exception is thrown.
To reproduce: 
- Bind the grid to a self reference data, it should contain nullable bool value as well.
- Add checkbox column:
GridViewCheckBoxColumn chkBoxColumn = new GridViewCheckBoxColumn();
chkBoxColumn.EnableHeaderCheckBox = true;
chkBoxColumn.ThreeState = true;
chkBoxColumn.EditMode = EditMode.OnValueChange;

- Start and uncheck and check one of the cells (in a data row)

Workaround:
public class MyGridCheckBoxHeaderCellElement : GridCheckBoxHeaderCellElement
{
    public MyGridCheckBoxHeaderCellElement(GridViewColumn column, GridRowElement row) : base(column,row)
    {
    }

    protected override bool SetCheckBoxState()
    {
        bool hasNullValue = false;
        foreach (GridViewRowInfo row in this.ViewInfo.Rows)
        {
            object cellValue = row.Cells[this.ColumnIndex].Value;
            if (cellValue == null)
            {
                hasNullValue = true;
            }
        }

        if (!hasNullValue)
        {
            return base.SetCheckBoxState();
        }

        SetCheckBoxState(ToggleState.Indeterminate);
        return false;
    }
}
0 comments