4 Replies Latest reply on Jun 6, 2007 12:32 PM by Mimi_star

    2 Colums under 1 Header

    Rahul Mainkar
      Dear All,
      I am facing a problem in displaying 2 colums under one header. For ex If the header in my data grid is ' Amount' then I want two colums viz. 'Cash' and 'Cheques' under it. Any idea how to go about it.

      -------------------------
      Amount
      -------------------------
      |Cash | Cheque|
      | | |
      | | |
        • 1. Re: 2 Colums under 1 Header
          Josh Johnson Level 1
          I had this same issue awhile back. The suggestion then was to create custom renderers for the header and the cells so they look like so:
          ________________
          | Header |
          -----------------------------
          | Head 1 | Head2 |
          -----------------------------

          and

          ------------------------
          | Col 1 | Col2 |
          ------------------------

          Problem is that I never found a good way to keep the columns aligned with their headings, and I eventually gave up and changed the display. If you find an answer, please post. :)
          • 2. Re: 2 Colums under 1 Header
            Josh Johnson Level 1
            < sarcasm > Wow, I love how the Forums are nice enough to collapse any white space. </ sarcasm >
            • 3. Re: 2 Colums under 1 Header
              prince_john
              Hi,

              I had the same issue. At last i found the solution. Here is the code.

              I sent mxml code now. In my next i will attach actionscript code.


              regards,
              prince

              *.mxml

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()"
              xmlns:custom="CustomComponent.*">
              <mx:Script>
              <![CDATA[
              import mx.collections.ArrayCollection;

              [Bindable]
              public var ResultAC:ArrayCollection = new ArrayCollection();

              [Bindable]
              public var arrColumn:Array = [

              {headerText : "Test 1", dataField : "T01", multiHeader : "Spanned head"},
              {headerText : "Test 2", dataField : "T02", multiHeader : "Spanned head"},
              {headerText : "Test 3", dataField : "T03", multiHeader : "Spanned head"},
              {headerText : "Test 4", dataField : "T04", multiHeader : ""},
              {headerText : "Test 5", dataField : "T00", multiHeader : ""}];

              private function onCreationComplete():void
              {
              ResultAC.addItem({T04 : "value", T00 : "first", T01 : 112414, T02 : "C", T03 : "8"});
              ResultAC.addItem({T04 : "value", T00 : "second", T01 : 11223, T02 : "A", T03 : "4"});
              ResultAC.addItem({T04 : "value", T00 : "third", T01 : 35645, T02 : "D", T03 : "2"});
              ResultAC.addItem({T04 : "value", T00 : "fourth", T01 : 5766, T02 : "J", T03 : "1"});
              ResultAC.addItem({T04 : "value", T00 : "fifth", T01 : 5632, T02 : "B", T03 : "4"});
              }
              ]]>
              </mx:Script>
              <mx:Panel x="100" y="100" width="60%" height="60%">
              <custom:MHGrid id="grid1" width="100%" height="100%"
              ArrColumn="{arrColumn}" dataProvider="{ResultAC}" enableMerge="true"/>
              <!--mx:DataGrid id="grid2" width="100%" height="100%" dataProvider="{ResultAC}">
              <mx:columns>
              <mx:DataGridColumn dataField="T00" headerText="00"/>
              <mx:DataGridColumn dataField="T01" headerText="01"/>
              <mx:DataGridColumn dataField="T02" headerText="02"/>
              <mx:DataGridColumn dataField="T03" headerText="03"/>
              </mx:columns>
              </mx:DataGrid-->
              </mx:Panel>
              </mx:Application>

              • 4. Re: 2 Colums under 1 Header
                Mimi_star
                Hi Prince,

                Waiting for your actionscript code or some explanation to see if it fit my needs.

                Regards,
                Mimi