Completed
Last Updated: 10 Jul 2015 14:42 by ADMIN
ADMIN
Hristo
Created on: 16 Jun 2015 07:27
Category: GridView
Type: Bug Report
1
FIX. RadGridView - invalid cast exception in GridCheckBoxHeaderCellElement when fitlering, even though EnableHeaderCheckBox is set to false
Workaround: create a custom GridCheckBoxHeaderCellElement and override the Attach method

public class MyGridCheckBoxHeaderCellElement : GridCheckBoxHeaderCellElement
{

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

	protected override Type ThemeEffectiveType {
		get { return typeof(GridHeaderCellElement); }
	}

	public override void Attach(GridViewColumn data, object context)
	{
		if (((GridViewCheckBoxColumn)data).EnableHeaderCheckBox) {
			base.Attach(data, context);
		} else {
			this.CheckBox.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
		}
	}
}

public Form1()
{
        InitializeComponent();
	this.radGridView1.CreateCell += radGridView1_CreateCell;
}


private void radGridView1_CreateCell(object sender, Telerik.WinControls.UI.GridViewCreateCellEventArgs e)
{
	if (e.CellType == typeof(GridCheckBoxHeaderCellElement)) {
		e.CellElement = new MyGridCheckBoxHeaderCellElement(e.Column, e.Row)
	}
}
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments