Rank: Member Groups: Member
Joined: 6/2/2008 Posts: 27
|
Is it possible to change the background color of a grid row when a CheckBoxColumn is selected client side?
TIA
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, I believe it is possible but not easy because there is no direct way to update a whole row's style from client side. You will need to handle the column's ClientSideEndEdit event and then update the styles for all cells for that row with JavaScript. To handle the columns' ClientSideEndEdit event:
Code: HTML/ASPX
<eo:CheckBoxColumn ClientSideOnEnd="on_checked" ....>
Code: JavaScript
function on_checked(cell, newValue)
{
......
}
Inside your handler you can call this function to update the cell style: http://doc.essentialobjects.com/library/1/jsdoc.public.gridcell.overridestyle.aspxUnfortunately there is no equivalent of overrideStyle on row level. It does make sense to have one though. So we will look into it and see if we can add it. Thanks!
|
Rank: Member Groups: Member
Joined: 6/2/2008 Posts: 27
|
Okay, thanks for the quick response. I didn't think there was a way but wanted to make sure. Below is the solution I came up.
var colCount = 21; function initGrid(){ var grid,itemCount,gridItem,gridCell,i,x; grid = eo_GetObject("grd"); itemCount = grid.getItemCount(); for (i=0;i<itemCount;i++){ gridItem = grid.getItem(i); if(gridItem.getCell(0).getValue() == 0) continue; for (x=1;x<=colCount;x++){ gridCell = gridItem.getCell(x); gridCell.overrideStyle("rowSelected"); } } } function end_edit_handler(cell, newValue){ var item = cell.getItem(); var i=0; var gridCell; for (i=1;i<=colCount;i++){ gridCell = item.getCell(i); if (newValue==1) gridCell.overrideStyle("rowSelected"); else gridCell.overrideStyle(null); } return newValue; }
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You are very welcome. Yes. That will work.
|