On Fri, Nov 5, 2010 at 17:25, Ken MacDonald <[email protected]> wrote:

> Hi,
> I've been displaying a table, but now we have a request to highlight
> certain rows in the table. I have a RowRenderer to handle the rendering,
> does highlights when row selected, etc. but wondering the best way to pass
> the "is a header" attribute for a particular row to be highlighted. So,
> something like:
>
> data = ["header 1", "row b", "row c", "this is a hdr, too", "row e", "row
> f"];   // this is really an array of arrays, not just strings!
> dataModel.setData(data);
>
> In my rowRenderer, I have a createRowStyle : function(rowInfo) which sets
> the colors for the row, etc. but the rowInfo param doesn't have much in the
> way of attributes - it has the row number (I could use this, I suppose, to
> remember that row 0 and row 3 are headers), but there's not much else to go
> on. Is there a way to attach a user attribute to rowInfo?
>
> What I did for the meantime is to add an additional invisible column to my
> data array (my table has only 1 visible column):
>
> Instead of
> data.append(["Im a header"]);
>
> I did:
> data.append(["Im a header", true]);
>
> and tested for the value of the invisible column in the RowRenderer to see
> if it should be treated as a header:
>
> if (rowInfo.rowData[1]) // render as header - different colors, etc.
>
> Works slick, but I'm just wondering if there's a more standard way to
> handle this.
>

It sounds like you're well familiar with the rowInfo map, which contains,
among other things, the entire row being rendered. The way you're doing it
is reasonable. An alternative is something like this in the data model,
assuming you have full control of the model:

var rows = [];

// A normal row
var row = [ 23, "hello world" ];
rows.push(row);

// A header row
row = [42, "I'm Special"];
row.bIsHeader = true;
rows.push(row);

When each row is now passed to your row renderer, you can check for
row.bIsHeader === true to know if it's a header row.

You're on the right track with what you're doing, and what I showed is just
an alternative that may or may not be better for your environment.

Derrell
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to