Welcome Guest Search | Active Topics | Sign In | Register

Accessing CheckboxColumn in Grid Options
David
Posted: Friday, April 2, 2010 3:10:42 AM
Rank: Advanced Member
Groups: Member

Joined: 10/21/2009
Posts: 39
I have a checkboxcolumn as defined below:

<eo:CheckBoxColumn Width="50" HeaderText="<input id='CheckboxDeleteAll' type='checkbox' onclick='ToggleCheckboxes()' />"></eo:CheckBoxColumn>

In the 'ToggleCheckboxes() function, how do I access all the checkboxes in the grid to select and deselect them?
eo_support
Posted: Friday, April 2, 2010 9:20:05 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,201
Hi,

You won't be able to access the checkboxes directly. You would access the grid cell and uses interface on the cell object to check/uncheck the checkboxes. This is necessary so that the Grid can properly update its internal data. The code will be something like this:

Code: JavaScript
var grid = eo_GetObject("Grid1");
for (var i = 0; i < grid.getItemCount(); i++)
{
    var item = grid.getItem(i);

    //This assumes the checkbox column is the first column
    var cell = item.getCell(0);

    //"1" = checked, "0" = unchecked
    cell.setValue("1");
}


Thanks!
David
Posted: Friday, April 2, 2010 6:13:07 PM
Rank: Advanced Member
Groups: Member

Joined: 10/21/2009
Posts: 39
Great, thanks.
Is there a way to get the value from the checkbox in the header?
eo_support
Posted: Friday, April 2, 2010 6:23:27 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,201
Hi,

You would use regular JavaScript/DOM to access it. The checkbox in the header is not managed by the Grid thus really has nothing to do with the Grid.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.