obj.refreshColours = function() {
var keys = this.getColouringKeys();
var colours = this.getColouringColours();
var column = this.getColouringColumn();
var rowIndices = this.getRowIndices();
for (var i=0; i<rowIndices.length; i++) {
// Get the value from the monitored column for the current row
var row = rowIndices[i];
var cellValue = this.getCellText(column, row);
// Check if the current cell value is one with a colour attached. If not, indexOf will return -1
var colourIndex = indexOf(keys, cellValue);
// If the current row isn't selected ..
if (indexOf(this.getSelectedRows(), row) == -1) {
// Set the text colour to black
this.getRowTemplate(row).setStyle("color", "black");
// If a colour needs to be applied, apply it. Otherwise apply white
if (colourIndex != -1)
this.getRowTemplate(row).setStyle("background-color", colours[colourIndex]);
else
this.getRowTemplate(row).setStyle("background-color", "white");
}
// Otherwise the row is selected, so apply the selected row settings
else {
this.getRowTemplate(row).setStyle("color", "white");
this.getRowTemplate(row).setStyle("background-color", "#316ac5");
}
}
}
This topic is archived.