:: Forum >>
Is there an equivalent to an "onCellLoad()" event for grid?
I apologize if this has been addressed, and I'm sure it has, however I've been wading through the forum for over an hour.
I'm want to test a cell value upon initial load (or setting of that cell value) and set the cell image based on that. I can do easily with the onCellValidated (et. al.). If not, what is the most efficient way to accomplish this? It would be great to just re-use this block rather than doing a loop through all the values. Here's my cell changed sample:
obj.onCellValidated = function(text, col, row){
// Yes, I know I can simply lower-case the text and set the
// css in one pass ...
if( col==3 ) {
switch(text) {
case "Complete":
obj.setCellImage("complete",col,row);
break;
case "Incomplete":
obj.setCellImage("incomplete",col,row);
break;
case "Waived":
obj.setCellImage("waived",col,row); break;
default: break;
}
}
};
Thanks in advance.
Curt K. :: California
Thursday, April 2, 2009
Anthony
Thursday, April 2, 2009
Thanks Anthony,
I have included a scaled-down sample. Perhaps you could correct/enhance the last part?
<style>
.aw-image-complete {
background-image: url(images/ok.png);
background-repeat: no-repeat;
}
.aw-image-waived {
background-image: url(images/hand.png);
background-repeat: no-repeat;
}
.aw-image-incomplete {
background-image: url(images/flag_red.png);
background-repeat: no-repeat;
}
</style>
grid.defineCellProperty("status-icon", function(col, row){
var text = this.getCellText(col, row);
return text.toLowerCase();
});
// assign background-color property to column-1 background
grid.getCellTemplate(3).setStyle("status-icon", function(){
return this.getControlProperty("status-icon");
});
// Something like this ...
cell.whenCellContentsChange(function(text,col,row) {
grid.setCellImage(text.toLowerCase(),col,row);
-or-
grid.setCellImage(this.getAttribute("status-icon"),col,row);
});
Curt K. :: California
Friday, April 3, 2009
Curt,
look at the sample code in /examples/images-using/grid cells.htm
Here is the statement which assigns the images -
grid.setCellImage(function(col, row){return myData[row][4]});
You can just put your switch statement inside this function and use getCellText(col, row) to retrieve the text value.
Alex (ActiveWidgets)
Friday, April 3, 2009
Thank you Alex, that works for me.
Curt K. :: California
Friday, April 3, 2009
This topic is archived.
Back to support forum
Forum search