Flex Tree ItemRenderer… put a refresh button on that folder

Filed under: Flex — Wrote by Campbell on Friday, October 13th, 2006 @ 5:00 pm

I checked through my MeasureMap stats last night and decided to check the search words that are leading to my site. Guess what. Alot of people are searching on tree Item renderers and datadescriptors. So in the first part of what I hope to be a many part ….um blog post here is how to put a button on a tree. Nothing special but it illustrates a few points and the basics. Remember you could change the button out to be an image or what ever.

SOURCE HERE or DOWNLOAD DA ZIP 

The biggest thing to note for someone venturing into the world of itemRenderers is that just because your itemrenderer is used for a node called bob the first time it is drawn doesnt mean it will be used for that same node (bob) after the parent node has been contracted and expanded again. So a good thing to do is pass the node data to your button (or what ever type) of class each time the itemrenderer updates, and evaluate what that class needs to do when it recieves this data. I made my Node getter in the class the trigger for this.

Also note that large collections in a tree can get pretty resource intensive. So try to make you ItemRenderers as effient as possible, by removing buttons etc if not needed. The day may come when your tree has thousands of nodes ekkkkkkkkkk. 

P.S. does anyone know of a good plugin for wordpress that embeds swfs with SWFObject? Im doing this more and more now and really want something easy. Work smart not hard and all that. 

13 Comments   -
  • Comment by Campbell | October 13, 2006 @ 11:54 pm

    For that wordpress plugin check out
    http://www.kimili.com/plugins/kml_flashembed/

  • Comment by Josh Tynjala | October 14, 2006 @ 5:13 am

    I always put my SWFs on a separate page with a screenshot linking to them in my posts. I figure it saves some bandwidth.

    Cool idea with the refresh button. Since you skinned the rest of the example, you should have made the buttons into refresh icons :)

  • Comment by Jed Wood | October 14, 2006 @ 8:56 am

    Just last night I tried 3 different WP-plugins for swf inclusion. Both the SWFObject ones gave me display problems, so I settled on Easy Inline SWF:

    http://wp-plugins.net/plugin/easyswf/#plugin_1591

    It really couldn’t be easier. I use the method of just setting the href of some link text to a .swf file, and the plugin replaces that text with the .swf, auto-detecting the default size and everything.

    Too bad it’s not the cool Javascript SWFObject / UFO way, but for the convenience? I’ll take it for WP posts and just use UFO for my “real” projects.

    -Jed

  • Comment by Tatya Plosh | October 14, 2006 @ 10:53 am

    Can this be developed in Flex 1.5 ?

    Thanks,
    New Bee

  • Comment by Campbell | October 16, 2006 @ 1:44 am

    Josh >> yeah I spose for the sake of prettyness I should :)
    Tatya >> Dude I really have no idea lol. From memory Flex 1.5 framework didnt have ItemRenderers like this. sorry bro!

  • Comment by Randall | October 18, 2006 @ 5:56 am

    I modified this code, and added a TextArea child inside the item Renderer. It works great, however there seems to be no way to control where the icon or label are displayed. They seem to float left justified and centered between the top and bottom of the Tree items (cells). I’m having to use absolute coordinates on my TextArea to keep it out of the way. My questions is if you know how to control the display location of the icon and/or label? These seem to be displayed by the super.updateDisplayList function, and therefore display where they want to, regardless of what other visual objects are in the item (cell). Is it possible to layout boxes, and put the icon and label into one of them? If so, can you give us a quick example of this?

  • Comment by Campbell | October 18, 2006 @ 9:04 am

    Yep thats possible Randal, Ill whip one up tonight. Ask and yeee shal recieve :)

  • Comment by prashant javiya | July 18, 2007 @ 5:34 pm

    i run this demo, i got problem,

    first i had expanded the mail node,
    after that i had expanded the personal folder node,
    after that i press refresh button of personal folder node,
    it display personal folder refresh button clicked,
    after pressing ok,
    i had collapsed the personal folder,
    after than i tried to expand this personal folder, it displayed error, like
    Error #2025 The suppliedDisplayObject must be a child of the caller.. like that

  • Comment by Campbell | July 18, 2007 @ 11:44 pm

    Yeah it was only really a demo and I guess there are more than a few bugs.

  • Comment by useable flex | August 23, 2007 @ 1:18 am

    Excellent, just what I needed, thanks :-) .. or I needed a couple of checkboxes instead of a button, but the switch was simple ;)

  • Comment by Campbell | August 23, 2007 @ 9:23 am

    Glad I could be of help useable flex :)

  • Comment by Marcus Fritze | April 2, 2008 @ 3:16 am

    I found this via google and this is really a good idea. I currently replace the button with variable text-label.

    It is not working yet.

    I will sent you the new code if you want.

  • Comment by Pol48 | October 23, 2009 @ 8:38 am

    If you want to ensure the survival of your printed product, you need to create a product that is both necessary and sufficient. ,

Leave your comment

© Flex developer, Campbell Anderson, from New Zealand – xsive blog -