v2.0 - Coloring cells based upon column data
I used the following code in v1.0. I cannot seem to find the 2.0 equivalent. Can sombody help me ?
mygrid.getColumnTemplate(6).setStyle("background-color", priorityBG);
var priorityBG = function() {
var priority = this.getItemProperty("text") + "";
if(priority == "STAT") return "#f39f96";
else return this.getProperty("row/order") % 2 ? "#EEEEEE" : "white";
}
metacove
February 10,
The main problem I am having is finding the function that replaces getColumnTemplate since that function is no longer valid.
metacove
February 10,
mygrid.getCellTemplate(6).setStyle("background-color", priorityBG);
var priorityBG = function () {
var row = mygrid.getCurrentRow();
var priority = mygrid.getCellText(6,row) + ""
if(priority == "STAT") {
return "red";
}
else return "green";
}
So far I have the above code but every row is getting colored red. I'm semi close but still new to the AW library. Any how would be greatly appreciated. I have been browsing the forums but haven't found the exact answer yet. My dataset is being populated via XML.
metacove
February 10,
Alright I'm slowly answering my own questions. I have everything working and only have a few questions left. I am using the following code to color a single cell based upon its value:
var row = mygrid.getCurrentRow();
mygrid.getCellTemplate(6, row).setStyle("background-color", priorityBG);
var priorityBG = function() {
var row = mygrid.getCurrentRow();
var priority = mygrid.getCellText(6,row) + ""
if(priority == "STAT") {
return "#f39f96";
}
else return row % 2 ? "#eeeeee" : "white";
}
I use the following code to handle my highlighted selection:
<style>
.aw-cells-selected,.aw-rows-selected, .aw-item-ruler {
color: black!important;
background-color: #ffe360!important;
}
</style>
Unfortunately the selection highlight doesn't apply to the cell I've recolored via the priorityBG function. Am I missing a CSS definition ? Do I need to handle my recolor differently to make this happen okay ? Any suggestions would be appreciated.
Thanks for a wonderful codebase to work with.
metacove
February 10,
I need to have the row selection color override any column color that I have set using getCellTemplate().setStyle("background-color","#....").
I accomplished this using !important in css. However, I only want this behavior to occur when I click on the row selector. Otherwise, I want the getCellTemplate color to override.
Is there a way to modify the code such that if I set a variable to true, the !important behavior takes precedence and if I set it to false, it would act as if the !important rule is not set?
Joel
November 25,
The other option I have is to programmatically de-select rows with the following code:
this.setRowSelected(false);
this.setRowState("");
this.setSelectedRows([]);
However, I don't want to do obj.refresh() and it appears I need to do the refresh.
Joel
November 25,