Hi there,
I am having some trouble implementing a "select all" checkbox for the RadGridView. I have successfully added checkboxes to group headers as shown in the attached screenshot. I need the ability to tick a box (which sits outside the grid) so it will select or deselect all items in the grid.
Currently when I click on the "select all" checkbox, only four items are selected in the grid out of 131. I believe this has something to do with the control reusing cells. I have implemented the following class.
I have also added the following code into the CreateCell event handler:
The variable _groupCheckboxes is intended to store the checkboxes for group headers. How can I ensure that this variable stores ALL checkboxes for group headers?
Thanks
I am having some trouble implementing a "select all" checkbox for the RadGridView. I have successfully added checkboxes to group headers as shown in the attached screenshot. I need the ability to tick a box (which sits outside the grid) so it will select or deselect all items in the grid.
Currently when I click on the "select all" checkbox, only four items are selected in the grid out of 131. I believe this has something to do with the control reusing cells. I have implemented the following class.
public
class
CustomGroupCellHeader : GridGroupContentCellElement
{
public
event
EventHandler CheckChanged;
public
RadCheckBoxElement Checkbox {
get
;
set
; }
public
GridViewColumn Column {
get
;
set
; }
public
GridRowElement Row {
get
;
set
; }
public
Guid OperatorId {
get
;
set
; }
public
string
OperatorName {
get
;
set
; }
public
CustomGroupCellHeader(GridViewColumn column, GridRowElement row) :
base
(column, row)
{
this
.Column = column;
this
.Row = row;
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
this
.Checkbox =
new
RadCheckBoxElement();
this
.Checkbox.MinSize =
new
Size(10, 10);
this
.Checkbox.ToggleStateChanged +=
new
StateChangedEventHandler(_checkbox_ToggleStateChanged);
this
.Children.Insert(0,
this
.Checkbox);
}
protected
override
System.Drawing.SizeF ArrangeOverride(System.Drawing.SizeF finalSize)
{
SizeF size =
base
.ArrangeOverride(finalSize);
RectangleF rect = GetClientRectangle(finalSize);
if
(
this
.Checkbox !=
null
)
{
this
.Checkbox.Arrange(
new
RectangleF(rect.X, rect.Y + 5, 10, 10));
}
return
size;
}
private
void
_checkbox_ToggleStateChanged(
object
sender, StateChangedEventArgs args)
{
if
(
this
.CheckChanged !=
null
)
{
this
.CheckChanged(
this
,
null
);
}
}
I have also added the following code into the CreateCell event handler:
private
List<CustomGroupCellHeader> _groupCheckboxes =
new
List<CustomGroupCellHeader>();
private
void
results_CreateCell(
object
sender, GridViewCreateCellEventArgs e)
{
if
(e.CellType ==
typeof
(GridGroupContentCellElement))
{
CustomGroupCellHeader customCell =
new
CustomGroupCellHeader(e.Column, e.Row);
customCell.CheckChanged +=
new
EventHandler(customCell_CheckChanged);
e.CellElement = customCell;
_groupCheckboxes.Add(customCell);
}
}
The variable _groupCheckboxes is intended to store the checkboxes for group headers. How can I ensure that this variable stores ALL checkboxes for group headers?
Thanks