Welcome Guest Search | Active Topics | Sign In | Register

Chnage grid item background color when checkbox is checked Options
Tim
Posted: Monday, March 29, 2010 5:35:03 PM
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
eo_support
Posted: Monday, March 29, 2010 6:19:10 PM
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.aspx

Unfortunately 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!
Tim
Posted: Monday, March 29, 2010 8:33:34 PM
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;
}
eo_support
Posted: Monday, March 29, 2010 8:38:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You are very welcome. Yes. That will work.


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.