Musings on AdvancedDataGrid (Part 3)

english mobile

Review Part 2

The author of the blog post I originally found that inspired this journey said that this method would not cause the selection and rollover indicators to be obscured in the same way as this method. But I really wanted to be able to see these indicators, rather than a tiny edge around each row. So I was determined that I was going to get my AdvancedDatagridItemRenderer to allow me to see these indicators through it.

The first thing I'd tried, just setting the alpha property, hadn't worked. The next thing I tried was to try to use the graphics functions to draw a background like I did in the AdvancedDatagridGroupItemRenderer. Unfortunately, since the AdvancedDatagridItemRenderer does not inherit from UIComponent or DisplayObjectContainer, so it neither had a graphics object of its own nor any way to add one.

So I stuck my nose back into the docs and discovered that my TextField had a colorTransform object that I should be able to manipulate to change the alpha transparency. Well, I was able to change its alpha property, but there was absolutely no visible change.

Finally, I realized I was going to have to leave the Flex world and see what the Flash world had to offer. So I came across this post and was able to get the transparency by changing the blend mode. Still, my AdvancedDatagridItemRenderer and AdvancedDatagridGroupItemRenderer did not match, because the text in the AdvancedDatagridItemRenderer was semitransparent and the AdvancedDatagridGroupItemRenderer text was not. Lesson Number 2: Anything that inherits from TextField is only going to be able to support alpha transparency with difficulty, and even then the entire component, including the text, will be alpha transparent.

So I had the simple idea that I could use the AdvancedDatagridGroupItemRenderer to do all the item rendering.

Tomorrow, I will talk about getting the icons to render properly.

7 comments:

Michael said...

I was wondering if you could provide some more insight on your extension of AdvancedDataGridGroupItemRender. I'm attempting do modify the style of the label text in the grid depending on the contents but no matter the changes I make in my extension nothing changes in the display. Thanks

Amy B said...

You don't need to extend AdvancedDataGridGroupItemRenderer just to change the text style. Use the styleFunction property of the AdvancedDataGrid instead.

Anson said...

I used AdvancedDatagridGroupItemRenderer to do all the item rendering and it works fine. But when I scrolled the datagrid vertically, the custom background color appeared in other rows that did not satisfy the condition set in the styleFunction. It could be a bug in Flex. Any workaround would be much appreciated.

abhinav1singhal said...

I want to have a Label on my AdvancedDataGridGroupItemRenderer for a columnSpan =0
for example

ExpandableColumnRenderer extends AdvancedDataGridGroupItemRenderer{
}
so that I can show more Items on this ItemRenderer. But, this renderer does not work that way as its not adding child to it.

Basically, in a nutshell I want display for topnodes like this

+ {Top node value} {another Label}
- depth 2
- depth 2

Please help.

StoneCypher said...

Er.

Why aren't you just subclassing the grid and overriding drawRowBackground() ?

That means no alpha, no horsing around, the color is the row instead of the embedded control, selection still works as normal, et cetera.

Amy B said...

Because I was styling other things at the same time, and it doesn't make sense to have part of the styling handled by the styleFunction, and other parts handled somewhere else.

Additionally, correct me if I'm wrong, but the drawRowBackground() function draws the rollover indicator as well, so you'd have to calculate the color of a styled row color based on the style and your rollover color, and, depending on how picky you are, you might even draw an alpha object of the styled color and then a larger opaque object of the rollover color. Stops looking very simple at that point :).

sunit82 said...

Can we use ItemRenderers in 2nd and 3rd depth levels of a treecolumn in a tree mode of AdvancedDataGrid?

I have been able to use ItemRenderer in the 3rd depth level of an AdvancedDataGrid.

If I use ItemRenderer in both the 2nd and 3rd level, then its rendered in the 2nd level but then that cell loses its tree mode i.e. it doesn’t have the “tree collapsing icon”. So there is no way to view the 3rd level. So effectively only 2 level are visible.

Thanx