Thanks Michael for the sample.
Definitely a step closer to the goal.
Tim
--- In flexcoders@yahoogroups.com, "Michael Montagna" <[EMAIL PROTECTED]>
wrote:
>
>
> --- In flexcoders@yahoogroups.com, "sufibaba" <sufibaba@> wrote:
> >
> > Hi Flex Team,
> >
> > Wondering if there is a working example for Beta3. The example in the
> > docs is not working.
> >
> > Flex 2.0 Developer's Guide > Building User Interfaces to
> > Flex Applications > Using Data Providers and Collections > Creating a
> > custom data descriptor
> >
> > Thanks,
> >
> > Tim
> >
>
> Here's a simple example descriptor that handles XML structures with no
> frills (no attribute flags, dnd, empty branches, etc) but should
> demonstrate the concepts.
>
> Note: For beta3, you'll probably want to add null checks to get/has/is
> methods, but post b3, the descriptor will not be sent null unless its in
> your dataset.
>
> ExampleTree.mxml
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
>
> <mx:Tree width="250"
> showRoot="true"
> labelField="@label"
> dataDescriptor="{new ExampleDescriptor()}">
> <mx:dataProvider>
> <mx:XML id="treeDP">
> <node label="Mail">
> <node label="Inbox"/>
> <node label="PersonalFolder">
> <node label="Demo"/>
> <node label="Personal"/>
> <node label="SavedMail"/>
> </node>
> <node label="Calendar"/>
> <node label="Sent"/>
> <node label="Trash"/>
> </node>
> </mx:XML>
> </mx:dataProvider>
> </mx:Tree>
> </mx:Application>
>
>
> ExampleDescriptor.as
> package
> {
> import mx.collections.ICollectionView;
> import mx.collections.XMLListCollection;
> import mx.controls.treeClasses.ITreeDataDescriptor;
>
> public class ExampleDescriptor implements ITreeDataDescriptor
> {
> public function ExampleDescriptor()
> {
> super();
> }
>
> public function getChildren(node:Object,
> model:Object=null):ICollectionView
> {
> return new XMLListCollection(node.*);
> }
>
> public function isBranch(node:Object,
model:Object=null):Boolean
> {
> return XMLList(node.*).length() > 0;
> }
>
> public function hasChildren(node:Object,
> model:Object=null):Boolean
> {
> return isBranch(node, model);
> }
>
> public function getData(node:Object, model:Object=null):Object
> {
> return Object(node);
> }
>
> //Drag and drop support methods below
> public function addChildAt(parent:Object,
> newChild:Object,
> index:int,
> model:Object=null):Boolean
> {
> return false;
> }
>
> public function removeChildAt(parent:Object,
> child:Object,
> index:int,
> model:Object=null):Boolean
> {
> return false;
> }
>
> }
> }
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development | Computer software development | Software design and development |
Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.