Skip navigation
Pigg_Man
Currently Being Moderated

How to get AdvancedDataGrid ItemRenderer for hierarchal column to work

Mar 17, 2008 4:12 PM

I have an advanced datagrid with 5 columns one of which is a hierarchal (tree). This datagrid is populated by the following:
MyAdvancedDataGrid.dataProvider = new HierarchicalData(MyXMLListCollection);

The first column is the tree and im trying to do a item renderer on it in actionscript... I have the following code:
MyTreeColumn.itemRenderer = new ClassFactory(MyRenderer);

In order to get the icon and label to show up i need to extend AdvancedDataGridGroupItemRenderer as such:
MyRenderer extends AdvancedDataGridGroupItemRenderer

This has one problem... the updateDisplayList function only gets fired for the children not the root rows... So if you set the this.icon.visible = false... the icon will show up on the root rows but the most bottom children rows the icon will become invisible...

Now ... if i extend the class with AdvancedDataGridItemRenderer then the tree functionality gets overwritten and it doesn't function the way that I need it to.. Ultimately I'm trying to shift the default label over so I can add another icon to the right of the the default icon so the user can click on it... Any help from anyone would be greatly appreciated...
 
Replies
  • Currently Being Moderated
    Mar 17, 2008 11:28 PM   in reply to Pigg_Man
    Find sample source here which adds a check box. You can modify it to show another icon.

    http://sreenivas.ramaswamy.googlepages.com/AdvancedDatagridSamples.zip
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2008 3:40 PM   in reply to Sreenivas R
    Hello,
    I have looked at this example and it uses AdvancedDataGridGroupItemRenderer. Can you point me in the direction of any examples that use CheckBoxes in other columns (e.g. not in the tree column). To do this, I assume you have to use AdvancedDataGridItemRenderer. Thanks.
    Jason
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2008 10:52 PM   in reply to Pigg_Man
    ADGItemRenderer directly derives from UITextField hence cannot be used to display anything else easily.

    If you want to use a simple CheckBox as a itemRenderer just specify it as itemRenderer for a ADGColumn.

    If you want to display some icons etc it would be easy to copy ADGGroupItemRenderer (or any other derived variaiton) remove its tree behavior code and use it.
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 24, 2008 9:02 AM   in reply to Sreenivas R
    I have gone the itemRenderer route that you recommended on a column. My itemRenderer extends HBox and has some logic to render the checkbox either selected or not selected and I am noticing some strange behavior. I overrode the set data function to hook the ADG into the renderer, is this the only function I need to override? When I scroll or re-size the browser, all the checkboxes reset to their original state. Here is my overriden method:

    override public function set data(value:Object):void {
    if(this.getChildren().length > 0) return;
    var ch:CheckBox = new CheckBox();
    if(data.isChecked) ch.selected = true;
    else ch.selected = false;
    addChild(ch);
    }

    This impl of set data returns if the checkboxes have already been setup, but now my data model and gui are not is sync. What is the best way to fix this?
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 24, 2008 9:09 AM   in reply to Pigg_Man
    Hey Pigg Man, I did not see your post, thank you for this code snippet, I will try it.
    Jason
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 25, 2008 8:02 AM   in reply to Pigg_Man
    I tried setting the property variableRowHeight="true" on the ADG in hopes that the row height would size itself to my itemRenderer UIComponent, but it is not. What is the best way to adjust the row height from the UIComponent itemRenderer such that it fits into the cell?
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 21, 2008 9:12 AM   in reply to Pigg_Man
    Hi,

    I'm struggling to get my head round creating item renderers in ActionScript. This example looks really good, but I'm trying to access the data from there and it's not working as _data is null, is there something immediately obvious that I'm doing wrong? Thanks.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points