Colspan in AdvancedDataGrid

Here is the simple example which illustrate possiblity using something similar to colspan in AdvancedDagaGrid:

Key classes: AdvancedDataGridRendererProvider and HierarchicalData

Lets build little application:

 

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    <![CDATA[
      import mx.collections.ArrayCollection;     
     [Bindable] private var dataC:ArrayCollection = new ArrayCollection([
     {type:"Discovery",value:"10",children:[{details:["Blah-blah-blah","Some other Blah-blah"]}]},
     {type:"Discovery",value:"10",children:[{details:["Blah-blah-blah","Some other Blah-blah"]}]},
     {type:"Discovery",value:"10",children:[{details:["Blah-blah-blah","Some other Blah-blah"]}]}]);
    ]]>
  </mx:Script>
    <mx:Panel title="Blah-Blah"
        height="75%" width="75%" layout="horizontal"
        paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
      <mx:AdvancedDataGrid id="myADG"
          width="100%" height="100%"
          variableRowHeight="true">
          <mx:dataProvider>
              <mx:HierarchicalData source="{dataC}">
              </mx:HierarchicalData>
          </mx:dataProvider>
          <mx:columns>
              <mx:AdvancedDataGridColumn dataField="type" headerText="type"/>
              <mx:AdvancedDataGridColumn dataField="value" headerText="value"/>
          </mx:columns>  
           
          <mx:rendererProviders>           
              <mx:AdvancedDataGridRendererProvider
                  dataField="details"
                  renderer="TaRenderer"
                  columnIndex="0"
                  columnSpan="0"/>        
          </mx:rendererProviders>
        </mx:AdvancedDataGrid>
    </mx:Panel>
</mx:Application>

 

AdvancedDataGridRendererProvideris the key here, it defines characteristic of single item renderer, basically tells ADG how to draw items. Anothe key Class is HierarchicalData it used to crete tree-like structure which can be rendered by ADG and displayed using AdvancedDataGridRendererProvideris.

For all this working properly we need to have one additional class, item renderer. In our case it is simple TextArea, which specified like renderer property of AdvancedDataGridRendererProvider.

<?xml version="1.0" encoding="utf-8"?>
<mx:TextArea xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" text="{data.details}">
</mx:TextArea>

Item renderer shoul have datafield specified. For this kind of simple renderer it is overkill to make separate class we could just include it like inline component, but anyways.

I hope this article was useful for you.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.
all information is copyright of riahut.com