3 Replies Latest reply on Nov 25, 2009 1:36 AM by manishmulani

    about data object

    manishmulani

      Hello everyone,

       

      I'm somewhat new to flex. I've this doubt since many days.

       

      I've seen this

       

      for eg: DataGridColumn dataField="{data.something}"

       

      in many places. what is data here ?? It's not defined anywhere. Is it some default which points to source of the data.

      Please clarify.

       

      I also tried this.

       

      <mx:DataGrid dataProvider="{myXML.books}">

      <columns>

           <mx:DataGridColumn dataField="{data.book}"/>

      </columns>

      </mx:DataGrid>

       

      but this doesn't work as expected. (Assuming I've this XML <books><book>hello</book><book>wow</book></books>)

       

      Please help

       

      Thanks,

      Manish

        • 1. Re: about data object
          paul.williams Level 4

          I think you may have seen something like this:

           

          <mx:DataGridColumn
              dataField="image" headerText="Image"
                  width="150">
                  <mx:itemRenderer>
                      <mx:Component>
                                  <mx:VBox
                                      width="100%" height="140"
                                      horizontalAlign="center" verticalAlign="middle">
                                          <mx:Image source="{'assets/'+data.image}"/>
                                          <mx:Label text="{data.image}" />
                                  </mx:VBox>
                          </mx:Component>
                  </mx:itemRenderer>
          </mx:DataGridColumn>


          In this case 'data' is a property of the item renderer. In order to be used as an item renderer, a component must expose a 'data' property.
          The 'data' property is populated with the relevant item from the dataProvider.

           

          The dataField property tells a column what property of a dataProvider item to display. So dataField="data" would tell the column to display the data property of the item. If your items don't have a "data" property then nothing will be displayed.

           

          This link may be helpful:

           

          http://www.adobe.com/devnet/flex/quickstart/using_item_renderers/

          • 2. Re: about data object
            msakrejda Level 4

            To follow up on Paul's response, for this example, try setting the dataField simply to 'book'.

            • 3. Re: about data object
              manishmulani Level 1

              Thank you for the help paul.williams