Flex TreeGrid

For a while I have been wanting to create a TreeGrid component for Flex. The
basic idea is to allow a user to navigate a Tree like object within a
DataGrid. Well, I just finished a very hacky version 1:
Here are some problems with the current implementation:

  • I get strange flicker when mousing over the cells. Don’t know why.
  • If I resize the right column to cover part of the Title, the title doesn’t get clipped. Don’t know why.
  • The code looks only for children named “product”. I don’t know of a way to make this generic / configurable.
  • Only supports 3 levels because I can’t figure out how to do recursion in the disclosurePress function. When I tried to call another function to do recursion the recursive method never got called. Don’t know why.

Other than all that, it works decently. :) Any ActionScript experts out there, please help me out. :)

Here is the mxml code
Here is the cellRenderer code

Enjoy!

-James

  • Jose Lora

    You may want to disable sorting on the columns.

  • Matt

    setValue is creating too many objects. Every time it is called it is creating the disclosure icon and the label when in reality it should only create those once and then subsequently change those properties as appropriate. There is probably a memory leak as the old versions aren’t being destroyed and the flicker is because you’re seeing the new objects get created (you’ll notice that the normal cells on the right don’t flicker). setValue gets called a ton (every time the mouse enters and exits) so it needs to be more efficient.

  • latha

    Hi,

    I was finally able to convert the treeGrid code from flex 1.5 to flex 2.0 !

    Thanks to your code, it wasn’t as daunting a task as i had imagined. :)

  • Latha has managed to port your treeGrid code from flex 1.5 to 2.0…. Here’s the link –

    http://codercentral.blogspot.com/2006/10/using-treegrid-in-flex-20.html

  • The link is working fine for me. Check it out once again. :)

  • Anonymous

    As soon as I set sortableColumns to true and start sorting, data gets lost and the data left is messy.

  • James Ward

    Sorry sorting isn’t supported in this component.

  • Hi James,

    I found your treeGrid component a few days ago and it was all what i need !
    I use the version for flex 2 updated by Latha.

    But I found a little bug in the ‘openItem’ function.
    When you open items until 3rd level, then close first level and open it again the sublevels arn’t displayed properly.

    Here’s the ‘openItem’ function corrected :
    http://www.y-dow.info/treeGrid_openItem.txt

    Thanks for your work.

  • mckang

    when I resized treegrid hearder, appear scroll in each cell
    I want to disapper this scroll in cell treegrid

    please !!

  • Michal

    Hello James,

    as McKang wrote, it is possible to remove that horizontal scrollbar which appears in column when the column width is smaller as width of the text?? It is indeed unusable, because you don’t see anything, except that srollbar:)) thanks Michal

  • Michal

    Hi,

    forget this:) I’ve found the solution. It is simple. In MyTreeGridRenderer class add attribute horizontalScrollPolicy=”off” in canvas section. That’s it…:-)

  • Michal

    But I have another question. Does somebody know how to do it, that by clinking on a button, will be all rows (levels) expanded and reversal??? thx