4 Replies Latest reply on Dec 29, 2010 11:04 PM by BhaskerChari

    How to load images in FLEX datagrid using Actionscript

    Rajeshb_Flash

      Hello friends,

       

      I need a small help from you. i am working in flex and in flash builder 4. Now my requirement was, i want to display images inside datagrid. I found a solution in mxml when searching in net. But i need a solution in actionscript. Can anyone help me out. I am new to flex environment.

       

      i am attaching the mxml code along with this.

       

      your help will be appreciated.

       

      Rajesh

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <!--
      Derrick Grigg
      dgrigg@rogers.com
      http://www.dgrigg.com
      created on Nov 3, 2006

       

      A sample of how to extend and use a data grid to allow custom drag images instead
      of the default 'row' based image.
      -->
      <mx:Application
          xmlns:mx="http://www.adobe.com/2006/mxml"
          layout="absolute">
         
          <mx:ArrayCollection id="dataSource">
              <mx:Object image="assets/ibmlogo.jpg" name="Spy Camera" description="James Bond spy camera"/>
              <mx:Object image="http://www.dgrigg.com/samples/flex/datagriddragproxy/images/products/cantena.jpg" name="Antena" description="Can shaped antena"/>
              <mx:Object image="http://www.dgrigg.com/samples/flex/datagriddragproxy/images/products/globe.jpg" name="Floating globe" description="Gravity defying floating globe"/>
              <mx:Object image="http://www.dgrigg.com/samples/flex/datagriddragproxy/images/products/orb.jpg" name="Orb" description="Blue glowing orb"/>
              <mx:Object image="http://www.dgrigg.com/samples/flex/datagriddragproxy/images/products/putty.jpg" name="Putty" description="Reshapable putty"/>
              <mx:Object image="http://www.dgrigg.com/samples/flex/datagriddragproxy/images/products/radiowatch.jpg" name="Radio Watch" description="Dick Tracy style radio watch"/>
              <mx:Object image="http://www.dgrigg.com/samples/flex/datagriddragproxy/images/products/rover.jpg" name="RC Rovers" description="Battle RC Rovers"/>
              <mx:Object image="http://www.dgrigg.com/samples/flex/datagriddragproxy/images/products/ufo.jpg" name="Flying UFO" description="RC UFO for indoor-outdoor"/>
          </mx:ArrayCollection>
         
          <mx:VBox>
              <mx:DataGrid dataProvider="{dataSource}">
                 
                  <mx:columns>
                      <mx:DataGridColumn headerText="Product" dataField="name"/>
                      <mx:DataGridColumn headerText="Description" dataField="description"/>
                      <mx:DataGridColumn headerText="Image" dataField="image">
                          <mx:itemRenderer>
                              <mx:Component>
                                  <mx:Image source="{data.image}"/>
                              </mx:Component>
                          </mx:itemRenderer>
                      </mx:DataGridColumn>
                  </mx:columns>
              </mx:DataGrid>
          </mx:VBox>
      </mx:Application>