[flexcoders] Re: Using an XML file as a dataProvider and accessing its data

2008-01-14 Thread kenny14390
That was very helpful, thank you! Two follow up questions. 

What are the similarities/differences advantages/disadvantages of
using multiple Lists instead of DataGrid? For example, if the data of
the second column depends on the selection in the first column, I
found it easier to just make each column into a List and use the index
of the selected Item in the list as an index into the XML file's
elements and then populate the second List with the new Array.


Secondly, an XML file is already essentially in a tree structure, but
how can you use the file as a dataProvider for the Tree component in
Flex? The method outlined in the previous question of sequentially
populating Lists is basically just a makeshift Tree, but I'd like to
find out how to actually use the XML file as a provider for the Tree.


Thanks again to whoever can help answer these questions.


-Ricky

--- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote:

 You can do both.  Bottom line, the DataGrid requires a list of items.
 This can be an XMLList or Array, ONLY if you are certain you will not
 need to update the data items individually.  Best practice is to use an
 XMLListCollection, which is a collection of XML nodes, or an
 ArrayCollection of item value objects.  Each item in the collection
 produces a row.
 
  
 
 Given such a list of data items, each row of the DataGrid gets a
 reference to the data item producing it. You specify which property or
 attribute in the item goes in which column using the DataGridColumn
 object.  If the value you want is in a top-level property of the item
 (an attribute or first level child node of an XML item, or a top-level
 property of the item object) you can specify the dataField.  It the
 value you want is nested deeper in the item object, use labelFunction().
 
  
 
 There are many examples available.
 
  
 
 Tracy
 
  
 



RE: [flexcoders] Re: Using an XML file as a dataProvider and accessing its data

2008-01-14 Thread Tracy Spratt
For the functionality you describe, if I am understnding correctly,
multiple lists seems to be the only solution.  DataGrid is row oriented.
Use it if your data structure has a list of items.  If one list depends
on the selection of another, do as you have done.

 

Mx:Tree can take an XML node directly as a dataProvider.  Furthermore,
while the docs are ambiguous, the XML API dispatches the necessary
events to make the tree UI update automatically when the underlying data
is changed.

 

With Tree, it is easy to specify what yu want to display for each node,
using labelField for simple references, or labelFunction() to access
nested values.  You can use a custom TreeItemRenderer for even more
control.  It is NOT so easy to make the structure of the tree different
from the structure of the underlying XML. 

 

I have several examples of Tree on www.cflex.net.

 

Tracy



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of kenny14390
Sent: Monday, January 14, 2008 9:01 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Using an XML file as a dataProvider and
accessing its data

 

That was very helpful, thank you! Two follow up questions. 

What are the similarities/differences advantages/disadvantages of
using multiple Lists instead of DataGrid? For example, if the data of
the second column depends on the selection in the first column, I
found it easier to just make each column into a List and use the index
of the selected Item in the list as an index into the XML file's
elements and then populate the second List with the new Array.

Secondly, an XML file is already essentially in a tree structure, but
how can you use the file as a dataProvider for the Tree component in
Flex? The method outlined in the previous question of sequentially
populating Lists is basically just a makeshift Tree, but I'd like to
find out how to actually use the XML file as a provider for the Tree.

Thanks again to whoever can help answer these questions.

-Ricky

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Tracy Spratt [EMAIL PROTECTED] wrote:

 You can do both. Bottom line, the DataGrid requires a list of items.
 This can be an XMLList or Array, ONLY if you are certain you will not
 need to update the data items individually. Best practice is to use an
 XMLListCollection, which is a collection of XML nodes, or an
 ArrayCollection of item value objects. Each item in the collection
 produces a row.
 
 
 
 Given such a list of data items, each row of the DataGrid gets a
 reference to the data item producing it. You specify which property or
 attribute in the item goes in which column using the DataGridColumn
 object. If the value you want is in a top-level property of the item
 (an attribute or first level child node of an XML item, or a top-level
 property of the item object) you can specify the dataField. It the
 value you want is nested deeper in the item object, use
labelFunction().
 
 
 
 There are many examples available.
 
 
 
 Tracy