On Wed, Jun 2, 2010 at 15:40, SimplyNotes <[email protected]> wrote:
>
> Hi Derrel,
>
> thanks for the feedback and sorry for the late response.
>
> I still need some help with rendering specific branches.
>
> I want to understand the timing: to say when to call createRowStyle and
> updateDataRowElement
>
> Currently I do the following
> -add branch
> -set node cell style using nodeSetCellStyle
> -define the row info as suggested
> -call createRowStyle - problem here is I do have a branch/node ID but no
> row
> number. getRowFromNodeId doesn't work yet. I do set own attributes in
> rowInfo as well which are obviously not persistent
>
Nope. *YOU* don't ever call _createRowStyle. The table code calls it at the
appropriate time. What you need to do is create a class, say
custom.MyRowRenderer which extends qx.ui.table.rowrenderer.Default, that
overrides the _createRowStyle method.
Try plugging this into the playground:
qx.Class.define("custom.MyRowRenderer",
{
extend : qx.ui.table.rowrenderer.Default,
members :
{
createRowStyle : function(rowInfo)
{
var rowStyle = [ ];
// Get the default styles
rowStyle.push(this.base(arguments, rowInfo));
// Make every row that starts with an '1' in column 1 be white on red.
// Note that this will add additional attributes to the style string
that
// repeat what the superclass returned. You may instead want to copy
// the code from the superclass into here instead of calling it as I
did
// above.
var col1data = rowInfo.table.getTableModel().getValue(1, rowInfo.row);
if (qx.lang.String.startsWith(col1data.toString(), "1"))
{
rowStyle.push(";"); // separator from style string returned already
rowStyle.push("background-color:red;color:white");
}
// Give 'em a string (not an array)
return rowStyle.join("");
}
}
});
function createRandomRows(rowCount) {
var rowData = [];
var now = new Date().getTime();
var dateRange = 400 * 24 * 60 * 60 * 1000; // 400 days
var nextId = 0;
for (var row = 0; row < rowCount; row++) {
var date = new Date(now + Math.random() * dateRange - dateRange / 2);
rowData.push([ nextId++, Math.random() * 10000, date, (Math.random() >
0.5) ]);
}
return rowData;
}
// window
var win = new qx.ui.window.Window("Table").set({
layout : new qx.ui.layout.Grow(),
allowClose: false,
allowMinimize: false,
contentPadding: 0
});
this.getRoot().add(win);
win.moveTo(30, 40);
win.open();
// table model
var tableModel = new qx.ui.table.model.Simple();
tableModel.setColumns([ "ID", "A number", "A date", "Boolean" ]);
tableModel.setData(createRandomRows(1000));
// make second column editable
tableModel.setColumnEditable(1, true);
// table
var table = new qx.ui.table.Table(tableModel).set({
decorator: null
})
table.setDataRowRenderer(new custom.MyRowRenderer(table));
win.add(table);
var tcm = table.getTableColumnModel();
// Display a checkbox in column 3
tcm.setDataCellRenderer(3, new qx.ui.table.cellrenderer.Boolean());
// use a different header renderer
tcm.setHeaderCellRenderer(2, new qx.ui.table.headerrenderer.Icon(
"icon/16/apps/office-calendar.png", "A date"));
Cheers,
Derrell
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel