5 Replies Latest reply on Mar 2, 2008 3:02 PM by Michael_Latta

    Item Renderer in Advanced Data Grid

    Balaji_Kumar_G
      I have checkbox against each folder in the datagrid and binded to XMLListCollection. When the value in the field is true, i want that checkbox to be selected. Its not working. Here is the code. I want to know how item render is working in AdvancedDataGrid

      Thanks in advance.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">
      <mx:Script>
      <![CDATA[
      import mx.collections.HierarchicalData;
      import mx.collections.XMLListCollection;
      ]]>
      </mx:Script>

      <mx:XMLList id="dpHierarchyXML" >
      <Clegs>
      <Cleg name="Cleg1" sel="true">
      <FlightLeg createdDate="10/10/2008" effectiveDate="10/10/2008"
      endDate="10/10/2008" modifiedDate="10/12/2008"
      station="ATL" carrier="Delta"
      flightNo="9W756" acType="122"
      beginDate="10/10/2008" timeRange="10"
      doop="123" region="XYZ"
      year_duration="0.24" moons="0"
      cost="1250"
      />
      </Cleg>
      <Cleg name="Cleg2" sel="true">
      <FlightLeg createdDate="10/10/2008" effectiveDate="10/10/2008"
      endDate="10/10/2008" modifiedDate="10/12/2008"
      station="ATL" carrier="Delta"
      flightNo="9W756" acType="122"
      beginDate="10/10/2008" timeRange="10"
      doop="123" region="XYZ"
      year_duration="0.24" moons="0"
      cost="1250"
      />
      </Cleg>
      </Clegs>
      </mx:XMLList>

      <mx:AdvancedDataGrid
      id="adg"
      dataProvider="{new HierarchicalData(dpHierarchyXML.Cleg)}" rowCount="20"
      width="100%"
      treeColumn="{leg}"
      variableRowHeight="true"
      wordWrap="true" dropEnabled="true" dragEnabled="true" dragMoveEnabled="true" sortExpertMode="true"
      >

      <mx:columns>

      <mx:AdvancedDataGridColumn dataField="@sel"
      headerText=" " width="25" rendererIsEditor="true" editable="true" editorDataField="selected" />
      <mx:AdvancedDataGridColumn dataField="@name" id="leg"
      headerText="cLeg" />
      <mx:AdvancedDataGridColumn dataField="@createdDate"
      headerText="Created Date" />
      <mx:AdvancedDataGridColumn dataField="@effectiveDate"
      headerText="Effective Date" />
      <mx:AdvancedDataGridColumn dataField="@endDate"
      headerText="End Date" />
      <mx:AdvancedDataGridColumn dataField="@modifiedDate"
      headerText="Modified Date" />
      <mx:AdvancedDataGridColumn dataField="@station"
      headerText="Station" />
      <mx:AdvancedDataGridColumn dataField="@carrier"
      headerText="Carrier" />
      <mx:AdvancedDataGridColumn dataField="@flightNo"
      headerText="Flight No" />
      <mx:AdvancedDataGridColumn dataField="@acType"
      headerText="Account Type" />
      <mx:AdvancedDataGridColumn dataField="@beginDate"
      headerText="Begin Date" />
      <mx:AdvancedDataGridColumn dataField="@timeRange"
      headerText="Time Range" />
      <mx:AdvancedDataGridColumn dataField="@doop"
      headerText="DOOP" />
      <mx:AdvancedDataGridColumn dataField="@region"
      headerText="Region" />
      </mx:columns>
      <mx:rendererProviders>
      <mx:AdvancedDataGridRendererProvider columnIndex="0" columnSpan="1" depth="1" renderer="mx.controls.CheckBox">
      </mx:AdvancedDataGridRendererProvider>
      </mx:rendererProviders>

      </mx:AdvancedDataGrid>

      </mx:Application>
        • 1. Re: Item Renderer in Advanced Data Grid
          Michael_Latta
          I do not have time to look at your code, but here are a few issues I encountered:

          1) The value of the field must be true/false anything else (null) will mess things up.
          2) If you set rendererIsEditor you must set itemRenderer, not itemEditor to the class name you want (mx.controls.CheckBox in this case).
          3) Set editorDataField to "selected"
          4) Set the dataField to where the true/false value on your object is.

          I hope this helps.
          • 2. Re: Item Renderer in Advanced Data Grid
            Balaji_Kumar_G Level 1
            Hi Michael
            Thanks for your response. If you see my code i did all the 4 points as you said. I did sample program with DataGrid and its working. When i try with Advanced datagrid its not working.
            It would be great if you can look into the code

            Thanks in Advance
            • 3. Re: Item Renderer in Advanced Data Grid
              Michael_Latta Level 1
              I do not see that you have done any of the points I made.

              1) The grid needs to be editable not just the columns.
              2) You do not set an item editor only an item renderer.
              3) You do not have rendererIsEditor on any columns that I can see.
              4) I was not using a renderer provider, I just had the renderer/editor specified on each column.
              5) You do not set rendererDataField on any thing. While the docs say it should default, do not believe it.

              • 4. Re: Item Renderer in Advanced Data Grid
                Balaji_Kumar_G Level 1
                2) You do not set an item editor only an item renderer.
                <mx:AdvancedDataGridRendererProvider columnIndex="0" columnSpan="1" depth="1" renderer="mx.controls.CheckBox">

                3) You do not have rendererIsEditor on any columns that I can see.
                <mx:AdvancedDataGridColumn dataField="@sel"
                headerText=" " width="25" rendererIsEditor="true" editable="true" editorDataField="selected"/>


                If I use the itemrender for that column, i am gettting the check box for all the rows. Which i dont want . I want check box only for the folder node. so i am using renderer provider
                I want only one column to be editable
                • 5. Re: Item Renderer in Advanced Data Grid
                  Michael_Latta Level 1
                  Ok. Well I guess you have exhausted my use of that. Good luck.