The following example shows how.
When hierarchical XML (or Object based) data is fed into a HierachicalData (which implements IHierachicalData) and set as dataProvider to ADG it internally converts it into a HierarchicalCollectionView (implementing IHierarchicalCollectionView). The good news is that HierarchicalCollectionView provides the sort and filtering APIs which can be used to sort and filter the data very similar to flat data.
Click on the "Simple sort" button to see how the data gets sorted recursively. It doesn't do a good job as it mixes up parent and leaf items. If you are one those who expects everything according to the alphabetical order you may like it !
Click on the "Custom sort" button to see how the sorting can be customized to show the parent items at the top and leaf items at the bottom. The custom sort function uses the IHierarchicalData.canHaveChildren API to move the parent items up the ladder.
"Remove sort" does the obvious.
13 comments:
it took me so long to find the treeColumn property on the AdvancedDataGrid. I realize its a commercial offering from Adobe but not having access to the source leaves me guessing what I am overriding when I extend it. There are all sorts of cool things you can do with the ADG and the DataViews but It takes alot of digging to get your head around whats going on.
Hello!
In this short example I found exactly what I was looking for :-)
Thanks a lot and good job :-)
1.treeColumn property was added late in the cycle as we found that users want to customize the tree column position.
2. If you buy the FB Pro version ADG source would be available to you very similar to charts source which used to get unzipped into the source directory when valid license key is entered.
Wicked im just waiting for release and Im there mate :)
Thanks, this really helped me out. Flex is great but the designers chose some odd ways of doing stuff, and omitted some useful functions that are pretty standard for other types of data display.
nice post
web design company, web designer,
web design India,website design,web design
Dear Mr. Sreenivas, thank you for your work and for this blog.
Please, would you give me some advice how to (if possible) set EventListeners directly to those Tree icons (defaultLeafIcon, folderClosedIcon, folderOpenIcon, disclosureClosedIcon and disclosureOpenIcon)?
I'm still trying to found this information in web and in Adobe help, but results doesn't seems to be helpful at the moment.
Thank you very much again.
The icons are created and used by the itemRenderers like ADGItemRenderer and ADGGroupItemRenderer. So you have to derive from these itemRenderers and add event handlers there OR create new itemRenderers by copying code and do the needful.
Thank you for you attention, now everything works just fine. Flex rocks!
Very informative article, thank you very much for sharing this article with us. Web Design | Web Designer
Thanks for this example. I notice in your code that you are building and refreshing the sort on the button clicks. If I perform those operations immediately after setting the dataProvider, things don't work. Is there an event I need to listen for that tells me the dataProvider is ready to be sorted and refreshed?
One can use validateNow to force immediate validation of the dataProvider and do these operations.
Post a Comment