Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
brad carvey #1
E4X dot notation
I just got the Adobe Flex 3 "Training from the Source". I am trying to get the
E4X dot notation working and the book has an excellent example for testing dot
notation to generate a Tree List. Unfortunately, the example is written with
Flex 2 and a commercial plugin.
I have tried to create some simple code that would use a datagrid and allow
dot notation in the datafield. I want to specify a single dataprovider and
select datafield entries using dot notation.
The code below does not display anything. If I ccange the dataProvider to
"{groceryXML.category}", then change the first dataField to @name, I will get
Vegetables and Fruit under the Category Header,but the "product@name" does not
work.
I can generate lots of dataProviders. I can also do this with an
arrayCollection, but the book recommends using XML and not an arrayCollection.
I also have some issues with how to get a differnent elements inside of the
dataProvider when it is generated from an arrayCollection.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
width="800" height="286">
<mx:Script>
<![CDATA[
[Bindable]
public var groceryXML:XML =
<catalog>
<category name="vegetables">
<product name="lettuce" cost="1.95">
<unit>bag</unit>
<desc>Cleaned and bagged</desc>
</product>
<product name="carrots" cost="2.95">
<unit>pound</unit>
<desc>Baby carrots, cleaned and peeled</desc>
</product>
</category>
<category name="fruit">
<product name="apples" cost="1.95">
<unit>each</unit>
<desc>Sweet Fuji</desc>
</product>
<berries>
<product name="raspberries" cost="3.95">
<unit>pint</unit>
<desc>Firm and fresh</desc>
</product>
<product name="strawberries" cost="2.95">
<unit>pint</unit>
<desc>Deep red and juicy</desc>
</product>
</berries>
</category>
</catalog>;
]]>
</mx:Script>
<mx:Panel layout="absolute" left="10" top="10" right="10" bottom="10"
title="Groceries">
<mx:DataGrid id="groceryGrid" right="10" left="10" top="10" bottom="19"
dataProvider="{groceryXML.category}">
<mx:columns>
<mx:DataGridColumn headerText="Category" dataField="@name"/>
<mx:DataGridColumn headerText="Product" dataField="product@name"/>
<mx:DataGridColumn headerText="Cost" dataField="product@cost"/>
<mx:DataGridColumn headerText="Unit" dataField="product.unit"/>
<mx:DataGridColumn headerText="Description" dataField="product.desc"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:Application>
brad carvey Guest
-
CFCs & Dot Notation
Here is what I have. A CFC with filename amCurPatientCount.cfc which is located in the "components" folder under the webroot. I have been able to... -
component dot notation
I have a component in a subdirectory of my website, lets say widget.cfc, the full path on my linux (SuSE 8.2) box is... -
php and number notation
Hi, I have written my first PHP script, albeit one thats only about 10 lines long. It is one of a number of small procedures that I'd written... -
New Object Notation vs @{$hash{key}}
I think I am picking up some bad habits so maybe you guys can help. I currently use this notation @{$hash{key}} to access an array stored in a... -
ActionScipt notation.
Hi, From old habbit I have always used to write function like this: function(){ //some code } But i see in tutorials and other places the... -
VarioPegged #2
Re: E4X dot notation
The dataField property of a DG column expects a string. When you do
dataField="product.@name", you're trying to evaluate an E4X expression, but
instead you're just providing a string. You'd have to use label functions on
the DG column(s) to evaluate the expression.
Since you're looking to display all products in the DG, you should make that
node the data provider, then you can evaluate the parent nodes via a label
function. The XML was adjusted a bit for consistency.
See the attached code.
TS
VarioPegged Guest
-
MayLam18 #3
Re: E4X dot notation
Thanks VarioPegged.
Your code is very helpful to me.
May
MayLam18 Guest



Reply With Quote

