Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default Re: E4X dot notation

    Thanks VarioPegged.

    Your code is very helpful to me.

    May
    MayLam18 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139