Musings on AdvancedDataGrid (Part 2)

english mobile

Review Part 1

I'd found a neat little sample that shows how to change the background color on the row by extending AdvancedDataGridItemRenderer (ADGIR) to set the existing background and backgroundColor properties based on a style set on the component.

I had no trouble copying this, but I found that for some reason the entire first column stubbornly refused to pick up my carefully applied color. Undaunted, I set the itemRenderer property of the first column explicitly to my extended ADGIR.

The result I had was closer to what I wanted--most of the cells in that column now had the color my styleFunction had insisted upon--but the ones with the triangle in them remained white. Aha! Clearly this was a different thing altogether, so I went back to the docs and looked for inspiration. It seems that the uncolored cells were being rendered by another component, the AdvancedDataGridGroupItemRenderer (ADGGIR).

So I set about extending that worthy component. At first, I thought I'd be able to just cut and paste the code I'd modified for my ADGIR, but no such luck. Unfortunately, the ADGGIR had no background or backgroundColor properties. So I fell back on more conventional tactics, drawing a rectangular background on the component when the style changed. First lesson: the AdvancedDataGridItemRenderer is based on the Flash TextField component and the AdvancedGridGroupItemRenderer is based on UIComponent. These two components have completely different capabilities and must be dealt with in entirely different ways.

As soon as I saw my extended ADGGIR next to the extended ADGIR, I realized that the ADGIR was not yeilding to my attempts to set its alpha transparency. I'd included code in both to set the alpha transparency, but it was only working in the ADGGIR.

Tomorrow, I'll talk about my attempts to add alpha transparency to the ADGIR.

5 comments:

cindy said...

hi there-

am appreciating your blog, but I can't for the life of me get the ADG to show the rowColor as specified.. I copied the examples you referenced (extending the itemRenderer) verbatim, and no row background color is changing.. The font color does, so I know the method is getting called. Is there something I"m missing.. I thought maybe it's my use of HierarchicalData, but you are using that too, right?

Amy B said...

I didn't actually use the code that I pointed to...I made the modifications written up in my posts. It's really hard to say without seeing your code. You might want to ask your question on the Yahoo flexCoders group and post your code there.

Andy said...

So did you get your advanced data grid to change row colors and still highlight on mouse over and such like it does by default?

Amy B said...

I used an extended AdvancedDataGridGroupItemRenderer with an alpha style as described in parts 3 and 4. This allowed the indicators to be visible through the background color.

kingquattro said...

Hey Amy,
I have a similar issue that Cindy has, perhaps and example would help..