3.2.0

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
April 2,
It sounds like you probably want to modify the cell template. Have a look at http://www.activewidgets.com/aw.templates.cell/ and look at this forum topic http://www.activewidgets.com/javascript.forum.24619.5/setting-cell-colour-start-cell.html

That changes the cell style. Shouldn't be too hard to tailor it to modify the contents instead.
Anthony
April 2,
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
April 3,
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)
April 3,
Thank you Alex, that works for me.
Curt K. :: California
April 3,

This topic is archived.

See also:


Back to support forum