Here is the version of Martin Witteman's answer that works on the playground (1.6):
/** This renderer makes rows matching our conditions appear as different colours */ qx.Class.define("CustomRowRenderer", { extend : qx.ui.table.rowrenderer.Default, members : { /** Overridden to handle our custom logic for row colouring */ updateDataRowElement : function(rowInfo, rowElem) { // Call super first this.base(arguments, rowInfo, rowElem); // Get the current style var style = rowElem.style; // Don't overwrite the style on the focused / selected row if (!(rowInfo.focusedRow && this.getHighlightFocusRow()) && !rowInfo.selected) { // Apply our rule for row colouring style.backgroundColor = (rowInfo.rowData[1] > 5000) ? this._colors.bgcolEven : this._colors.bgcolOdd; } }, /** Overridden to handle our custom logic for row colouring */ createRowStyle : function(rowInfo) { // Create some style var rowStyle = []; rowStyle.push(";"); rowStyle.push(this.__fontStyleString); rowStyle.push("background-color:"); // Are we focused? if (rowInfo.focusedRow && this.getHighlightFocusRow()) { // Handle the focused / selected row as normal rowStyle.push(rowInfo.selected ? this._colors.bgcolFocusedSelected : this._colors.bgcolFocused); } else { // Aew we selected? if (rowInfo.selected) { // Handle the selected row as normal rowStyle.push(this._colors.bgcolSelected); } else { // Apply our rule for row colouring rowStyle.push((rowInfo.rowData[1] > 5000) ? this._colors.bgcolEven : this._colors.bgcolOdd); } } // Finish off the style string rowStyle.push(';color:'); rowStyle.push(rowInfo.selected ? this._colors.colSelected : this._colors.colNormal); rowStyle.push(';border-bottom: 1px solid ', this._colors.horLine); return rowStyle.join(""); } } }); // Demo table var tableModel = new qx.ui.table.model.Simple(); tableModel.setColumns([ "ID", "Number" ]); tableModel.setData([ [1, 5000], [1, 6000], [1, 6000], [1, 6000], [1, 6000], [1, 4000], [1, 4000], [1, 4000], [1, 6000] ]); var table = new qx.ui.table.Table(tableModel); // Apply our renderer table.setDataRowRenderer(new CustomRowRenderer(table)); // Add table this.getRoot().add(table, { left : 10, top : 10 });
source share