Tracy,

Yesterday, I took the code from your tree control sample and started creating an example for CFlex.  Are you doing something similar?  The sample that I'm working on contains code and tips from you, Graham Weldon, Tim (sufibaba - don't know last name) and Paul Williams.  I'm doing this mostly to learn the ins and outs of using an XML based tree control and to create somewhat of a template.  Since most of your recent posts have been tree related, I thought that I would ask your help with two things.  If you already have code that does the following functions, I would appreciate your help. 

1. Remove Selected Element and/or Node
2. Add New Element - I have code that does this, but I can't figure-out how to insert dynamic Inner XML (label based on the text in a textInput).

If you get a chance to look at this, it would definitly save me some time.  The sample is here:

http://www.iepl.net/treeControlSample/treeControlSample.html 

Thanks,
Tim Hoff

--- In flexcoders@yahoogroups.com, "Paul Williams" <[EMAIL PROTECTED]> wrote:
>
> Yes, the descendants method allows you to work with xml that contains
> reserved words. I don't know of any other reason to choose one above the
> other.
>
>
>
> Paul
>
>
>
> ________________________________
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Tracy Spratt
> Sent: Thursday, May 25, 2006 5:50 PM
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Re: XMLListCollection search [f2b3]
>
>
>
> As I recall, the dependents approach is safer regarding reserved words.
> Other than that, do you know of any reason to choose one over the other?
>
>
>
> Tracy
>
>
>
> ________________________________
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Paul Williams
> Sent: Thursday, May 25, 2006 4:45 AM
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Re: XMLListCollection search [f2b3]
>
>
>
> You can also achieve something similar with the '..' operator:
>
>
>
> _xmlData..element.(@eid == sId);
>
>
>
> Gives you any elements in your hierarchy that have a particular eid.
>
>
>
> ________________________________
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Tracy Spratt
> Sent: Thursday, May 25, 2006 5:24 AM
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Re: XMLListCollection search [f2b3]
>
>
>
> Got it. Here is a little sample app that lets you search for an
> attribute value, then expands the tree to that node and selects it.
>
> Tracy
>
>
>
> <?xml version="1.0" encoding="utf-8"?>
>
> <!-- Tree control example. -->
>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> creationComplete="initApp()">
>
> <mx:Script><![CDATA[
>
> [Bindable]
>
> public var _xmlData:XML;
>
>
>
> public function initApp():void
>
> {
>
> _xmlData = <element eid="hello">
>
> <element eid="world">
>
> <element eid="123"/>
>
> <element eid="graham"/>
>
> <element eid="weldon">
>
> <element eid="office">
>
> <element eid="thing"/>
>
> <element eid="boat"/>
>
> <element eid="chair"/>
>
> </element>
>
> <element eid="person"/>
>
> </element>
>
> </element>
>
> </element> ;
>
>
>
> }//initapp
>
>
>
> private function expandParents(xmlNode:XML):void
>
> {
>
> while (xmlNode.parent() != null) {
>
> xmlNode = xmlNode.parent();
>
> myTree.expandItem(xmlNode,true, false);
>
> }
>
> }//expandParents
>
>
>
>
>
> private function findNodeById(sId:String):void
>
> {
>
> var xmllistDescendants:XMLList =
> _xmlData.descendants().(@eid == sId);
>
> expandParents(xmllistDescendants[0]);
>
> myTree.selectedItem = xmllistDescendants[0];
>
> }//findNodeById
>
> ]]></mx:Script>
>
>
>
>
>
>
>
> <mx:Panel title="Tree Control Example" height="75%" width="75%"
>
> paddingTop="10" paddingLeft="10" paddingRight="10"
> paddingBottom="10">
>
> <mx:HBox>
>
> <mx:TextInput id="tiId" text="boat" />
>
> <mx:Button label="Find" click="findNodeById(tiId.text)" />
>
>
> </mx:HBox>
>
> <mx:Tree id="myTree" width="50%" height="100%" labelField="@eid"
>
> showRoot="false" dataProvider="{_xmlData}" />
>
> </mx:Panel>
>
> </mx:Application>
>
>
>
> ________________________________
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Graham Weldon
> Sent: Wednesday, May 24, 2006 11:46 PM
> To: flexcoders@yahoogroups.com
> Subject: Re: [flexcoders] Re: XMLListCollection search [f2b3]
>
>
>
> This works:
>
> var myXml : XMLList = new XMLList(<element id="hello">
> <element id="world">
> <element id="123"/>
> <element id="graham"/>
> <element id="weldon">
> <element id="office">
> <element id="thing"/>
> <element id="boat"/>
> <element id="chair"/>
> </element>
> <element id="person"/>
> </element>
> </element>
> </element>);
>
>
> var boatElement : XMLList = myXml.descendants().(@id == 'boat');
>
> But this could potentially (if the Id's were not unique) return more
> than one item. This is most likely a non issue for those that want to
> use it.
> You could then wrap this in an XMLListCollection if necessary:
>
> var boatCollection : XMLListCollection = new
> XMLListCollection(boatElement);
>
>
> Regards,
> Graham.
>
>
> Tracy Spratt wrote:
>
> Maybe not. I can't seem to get an _expression_ to work. Descendants is
> supposed to take a Qname though.. Still trying.
>
> Tracy
>
>
>
> ________________________________
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Tracy Spratt
> Sent: Wednesday, May 24, 2006 11:23 PM
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Re: XMLListCollection search [f2b3]
>
>
>
> That should be: (@id==sId)
>
>
>
> ________________________________
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Tracy Spratt
> Sent: Wednesday, May 24, 2006 11:13 PM
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Re: XMLListCollection search [f2b3]
>
>
>
> Graham,
>
> Won't e4x get you further than you are using it?
>
>
>
> Untested code:
>
> var xml:XML = <element id="hello">
> <element id="world">
> <element id="123"/>
> <element id="graham"/>
> <element id="weldon">
> <element id="office">
> <element id="thing"/>
> <element id="boat"/>
> <element id="chair"/>
> </element>
> <element id="person"/>
> </element>
> </element>
> </element>
>
>
>
> var sId:String = "boat";
>
> var xlc:XMLCollectionList = new
> XMLCOllectionList(xml.descendants(@id=sId)); //Should return a single
> ietm in the collection <element id="boat">
>
>
>
> Again, untested.
>
>
>
> Tracy
>
>
>
> ________________________________
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Graham Weldon
> Sent: Wednesday, May 24, 2006 10:08 PM
> To: flexcoders@yahoogroups.com
> Subject: Re: [flexcoders] Re: XMLListCollection search [f2b3]
>
>
>
> Hi Tim,
>
> A good suggestion. Unfortunately my collection is not sorted, and a sort
> would cause some issues with the display of the Tree that uses my
> collection as a dataProvider.
>
> Bryan,
> Your code example is good, but I feel that it will only work for 2
> levels of nodes.
> My XML structure has no limit to the number of levels of nodes. Thus its
> an n-level tree.
>
>
> I have however attempted the following approach with success! Please
> feel free to use this code sample:
>
>
> =============================================================
> ===== XML Example
> =============================================================
> <element id="hello">
> <element id="world">
> <element id="123"/>
> <element id="graham"/>
> <element id="weldon">
> <element id="office">
> <element id="thing"/>
> <element id="boat"/>
> <element id="chair"/>
> </element>
> <element id="person"/>
> </element>
> </element>
> </element>
> =============================================================
>
>
>
> =============================================================
> ===== FUNCTION: insertItem(_parentId, _child)
> =============================================================
> public function insertItem(_parentId : String, _child : XMLList) :
> Boolean
> {
> var parentElement : XMLList = this.findItem(_parentId);
> // ---- Exit if we didnt find the parent
> if (parentElement == null)
> return false;
>
> // ---- Add the child element to the parent's children collection
> parentElement.* += _child;
> return true;
> }
> =============================================================
>
>
>
> =============================================================
> ===== FUNCTION: findItem(_id, _xml)
> =============================================================
> public function findItem (_id : String, _xml : XMLList) : XMLList
> {
> // ---- Check if the supplied element is the one we're looking for
> if ([EMAIL PROTECTED] == _id)
> return _xml;
>
> var children : XMLList = _xml.element;
> var result : XMLList = null;
>
> for each (var x : XML in children)
> {
> // ---- Recurse, looking at children.
> result = this.findItem(_id, new XMLList(x));
> // ---- Return the result if its not null, ending the recursion
> if (result != null)
> return result;
> }
>
> return null;
> }
> =============================================================
>
>
>
>
> Regards,
> Graham Weldon
>
>
>
> Tim Hoff wrote:
>
> Hi Graham,
>
> I'm not sure if it works, but have you tried this approach?
>
> var myTreeData:ICollectionView = new XMLListCollection();
> var myCursor:IViewCursor = myArrayCollection.createCursor();
>
> myCursor.findFirst([EMAIL PROTECTED]:"9998"});
> // maybe just Id?. According to the docs, this only works if the
> collection is sorted.
>
> myCursor.insert({label:"thing", id:"9999"});
> // might be different syntax for XML
>
> -TH
>
> --- In flexcoders@yahoogroups.com, "Bryan Choi" oopchoi@
> <mailto:oopchoi@ wrote:
> >
> > Hi Graham,
> >
> > As you can see that my english is not good.
> >
> > If I can tell you in english well, might be is not now in Korea.
> >
> > So I told you how many it'll help you...
> >
> > I am so sorry.
> >
> > However, I think that you can understand it, if you know that AS
> 3.0 syntax.
> >
> > Any way, I am sad and wanna talk in english well.
> >
> > Regards,
> > Bryan Choi.
> >
> >
> > ----- Original Message -----
> > From: "Graham Weldon" graham.weldon@ <mailto:graham.weldon@
> > To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com
> > Sent: Thursday, May 25, 2006 9:59 AM
> > Subject: Re: [flexcoders] XMLListCollection search [f2b3]
> >
> >
> > >
> > > Hi Bryan,
> > >
> > > Thanks for that link. Unfortunately I don't read Korean too well
> (at all).
> > > Do you know if there is an English translation for this
> discussion, or
> > > do you have some code samples that are commented in English?
> > >
> > > Regards,
> > > Graham Weldon
> > > \
> > >
> > >
> > > Bryan Choi wrote:
> > >
> > >> Hi, Graham Weldon.
> > >>
> > >> I am a Korean.
> > >>
> > >> I explained it on my community.
> > >>
> > >> You can see from the url (
> http://cafe.naver.com/flexcomponent/665 )
> > >>
> > >> Actually, I was helped flexcoders members.
> > >>
> > >> So I'll show you and many Korean.
> > >>
> > >> I don't know how many it'll help you to know it.
> > >>
> > >> Thank you,
> > >> Bryan.
> > >>
> > >>
> > >> ----- Original Message -----
> > >> From: "Graham Weldon" graham.weldon@
> <mailto:graham.weldon@
> > >> To: flexcoders@yahoogroups.com
> <mailto:flexcoders@yahoogroups.com
> > >> Sent: Thursday, May 25, 2006 9:05 AM
> > >> Subject: [flexcoders] XMLListCollection search [f2b3]
> > >>
> > >>
> > >> > Hi all,
> > >> >
> > >> > I'm wondering if anyone has had any experience or has some
> samples for
> > >> > searching an XMLListCollection for a particular item?
> > >> > I have a nested structure of <element>'s, each having an "id"
> > >> attribute.
> > >> > I would like to be able to do something like:
> > >> >
> > >> > var myXmlListCollection : XMLListCollection = new
> XMLListCollection(
> > >> ...
> > >> > some data source ... );
> > >> > var item : *** = findItem(myXmlListCollection, 'MyUniqueId');
> > >> > trace (item.toString());
> > >> >
> > >> > I am unsure of the class type of variable "item" in this
> example. I
> > >> want
> > >> > to be able to add in an element using "item" as the parent.
> So the data
> > >> > type used needs to allow this type of operation. The next
> step will be
> > >> > to add a child to this found item.
> > >> >
> > >> > Any thoughts?
> > >> >
> > >> > Regards,
> > >> > Graham Weldon
> > >> >
> > >> >
> > >> >
> > >> > --
> > >> > Flexcoders Mailing List
> > >> > FAQ:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > >> > Search Archives:
> > >> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > >> > Yahoo! Groups Links
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >>
> > >> --
> > >> Flexcoders Mailing List
> > >> FAQ:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > >> Search Archives: http://www.mail-archive.com/flexcoders%
> <http://www.mail-archive.com/flexcoders%25>
> 40yahoogroups.com
> > >>
> > >>
> > >>
> > >> SPONSORED LINKS
> > >> Web site design development
> > >> <http://groups.yahoo.com/gads?
> t=ms&k=Web+site+design+development&w1=Web+site+design+development&w2=
> Computer+software+development&w3=Software+design+and+development&w4=M
> acromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=L
> -4QTvxB_quFDtMyhrQaHQ>
> > >> Computer software development
> > >> <http://groups.yahoo.com/gads?
> t=ms&k=Computer+software+development&w1=Web+site+design+development&w
> 2=Computer+software+development&w3=Software+design+and+development&w4
> =Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig
> =lvQjSRfQDfWudJSe1lLjHw>
> > >> Software design and development
> > >> <http://groups.yahoo.com/gads?
> t=ms&k=Software+design+and+development&w1=Web+site+design+development
> &w2=Computer+software+development&w3=Software+design+and+development&
> w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.s
> ig=1pMBCdo3DsJbuU9AEmO1oQ>
> > >>
> > >> Macromedia flex
> > >> <http://groups.yahoo.com/gads?
> t=ms&k=Macromedia+flex&w1=Web+site+design+development&w2=Computer+sof
> tware+development&w3=Software+design+and+development&w4=Macromedia+fl
> ex&w5=Software+development+best+practice&c=5&s=166&.sig=OO6nPIrz7_EpZ
> I36cYzBjw>
> > >> Software development best practice
> > >> <http://groups.yahoo.com/gads?
> t=ms&k=Software+development+best+practice&w1=Web+site+design+developm
> ent&w2=Computer+software+development&w3=Software+design+and+developme
> nt&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166
> &.sig=f89quyyulIDsnABLD6IXIw>
> > >>
> > >>
> > >>
> > >> ----------------------------------------------------------------
> --------
> > >> YAHOO! GROUPS LINKS
> > >>
> > >> * Visit your group "flexcoders
> > >> <http://groups.yahoo.com/group/flexcoders>" on the web.
> > >>
> > >> * To unsubscribe from this group, send an email to:
> > >> [EMAIL PROTECTED]
> > >> <mailto:[EMAIL PROTECTED]
> subject=Unsubscribe>
> > >>
> > >> * Your use of Yahoo! Groups is subject to the Yahoo! Terms
> of
> > >> Service <http://docs.yahoo.com/info/terms/>.
> > >>
> > >>
> > >> ----------------------------------------------------------------
> --------
> > >>
> > >
> > >
> > >
> > > ------------------------ Yahoo! Groups Sponsor ------------------
> --~-->
> > > Get to your groups with one click. Know instantly when new email
> arrives
> > > http://us.click.yahoo.com/.7bhrC/MGxNAA/yQLSAA/nhFolB/TM
> > > -----------------------------------------------------------------
> ---~->
> > >
> > > --
> > > Flexcoders Mailing List
> > > FAQ:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > Search Archives: http://www.mail-archive.com/flexcoders%
> <http://www.mail-archive.com/flexcoders%25>
> 40yahoogroups.com
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
>
>
>
>
>
>
>
>
>
>
>
> --
> 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
> <http://groups.yahoo.com/gads?t=ms&k=Web+site+design+development&w1=Web+
> site+design+development&w2=Computer+software+development&w3=Software+des
> ign+and+development&w4=Macromedia+flex&w5=Software+development+best+prac
> tice&c=5&s=166&.sig=L-4QTvxB_quFDtMyhrQaHQ>
>
> Computer software development
> <http://groups.yahoo.com/gads?t=ms&k=Computer+software+development&w1=We
> b+site+design+development&w2=Computer+software+development&w3=Software+d
> esign+and+development&w4=Macromedia+flex&w5=Software+development+best+pr
> actice&c=5&s=166&.sig=lvQjSRfQDfWudJSe1lLjHw>
>
> Software design and development
> <http://groups.yahoo.com/gads?t=ms&k=Software+design+and+development&w1=
> Web+site+design+development&w2=Computer+software+development&w3=Software
> +design+and+development&w4=Macromedia+flex&w5=Software+development+best+
> practice&c=5&s=166&.sig=1pMBCdo3DsJbuU9AEmO1oQ>
>
> Macromedia flex
> <http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Web+site+design+
> development&w2=Computer+software+development&w3=Software+design+and+deve
> lopment&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=1
> 66&.sig=OO6nPIrz7_EpZI36cYzBjw>
>
> Software development best practice
> <http://groups.yahoo.com/gads?t=ms&k=Software+development+best+practice&
> w1=Web+site+design+development&w2=Computer+software+development&w3=Softw
> are+design+and+development&w4=Macromedia+flex&w5=Software+development+be
> st+practice&c=5&s=166&.sig=f89quyyulIDsnABLD6IXIw>
>
>
>
>
>
> ________________________________
>
> YAHOO! GROUPS LINKS
>
>
>
> * Visit your group "flexcoders
> <http://groups.yahoo.com/group/flexcoders> " on the web.
>
> * To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> .
>
>
>
> ________________________________
>



--
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




Reply via email to