Monday, June 25, 2007

addendum AS3 E4X: Sorting Hierarchical XML Data for Tree Control

I’ve taken some private and thankfully friendly flak about my preceding post on sorting data in an XML object for the purpose of providing data to a tree control.  I'm told I should use the ItreeDataDescriptor interface to get into the real spirit of Flex.

I did a little homework and learned a few things that should have been part of the preceding post.  At this point, I'm not going to create a class implementing ItreeDataDescriptor but I’ll keep an open mind on the subject.  However I did have some misunderstandings about what I was doing.  (I did mention on my first post, this blog would be a journal of my experiences and I’m new to Flex.)

When you set the Tree control’s dataProvider property to an XML object, it gets converted internally to an XMLListCollection which I have verified by running a trace.

The official Adobe documentation is wrong.  It does say that 3 object types get converted to an XMLListCollection: a valid XML string, an XMLNode, and an XMLList.  I suppose it is reasonable to assume if a valid XML string is converted along with an XMLList object, then an XML object would be also.

Okay, I didn't actually read the documentation on a Tree's dataProvider before writing my code.  I assumed all dataProvider's would be the same. I'm not sure where my basic knowledge of dataProvider's came from but it was probably from Adobe's "Training from the Source".  And anyway, the documentation is wrong.

The first thing I should have done, and I don't know why I don't do this all of the time, is look at the Flex source code.  Sometimes it takes a while to weed through the code, but this time it took all of 30 seconds to verify:  When you set a Tree's dataProvider to an XML object, it gets converted internally to an XMLListCollection object.

The embarrassing thing about my previous post is that I was contrasting how well I could get an XML object to work but blasting the XMLListCollection as a Tree’s dataProvider.  My real problem was trying to sort descendents and I haven’t figured how to do that with XMLListCollection’s.  I’m sticking with the XML sort and plan to expand upon it real soon.

8 comments:

Rodrigo said...

Oi, achei teu blog pelo google tá bem interessante gostei desse post. Quando der dá uma passada pelo meu blog, é sobre camisetas personalizadas, mostra passo a passo como criar uma camiseta personalizada bem maneira. Até mais.

Jim said...

Thanks, Rodrigo. You have a vey impressive website, http://www.camisaonline.com.br/. Very fast.

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

What words... super, a remarkable phrase

Anonymous said...

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

Anonymous said...

Good dispatch and this fill someone in on helped me alot in my college assignement. Thank you as your information.

Anonymous said...

Easily I assent to but I dream the list inform should acquire more info then it has.

Anonymous said...

Good fill someone in on and this mail helped me alot in my college assignement. Thanks you on your information.