2 Replies Latest reply on Jul 13, 2009 12:50 AM by leybniz

    Need help : How to set last datagrid column width to defined width irrespective of total width available

    maheshrox

      Hi everybody !!! i need a suggestion from you about how to set last datagrid column width to defined width. Even i had set the last datagrid column width to some specified pixels it dint work.

       

      Scenario :

       

      >> I created datagrid and set width to 800

      >> created six datagrid columns and assigned width to 300 each.

      >> when i scroll horizontally, the last datagrid column width is more than what i have assigned.

       

      What i have perceived from this issue is, when you scroll horizontally it gets total width and start to layout datagrid columns except last. Once it has been assigned all except last, it assigns total remaining space to last data grid column width instead of defined width.

       

      Code :

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="800" creationComplete="onInit()"  xmlns:port="*" layout="vertical">
         
          <mx:Script>
              <![CDATA[
                  import mx.controls.dataGridClasses.DataGridItemRenderer;
                  import mx.collections.SortField;
                  import mx.collections.Sort;
                  import mx.events.DataGridEvent;
                  import mx.events.ScrollEvent;
                  import mx.collections.ArrayCollection;
                 
                  [Bindable]public var ac : ArrayCollection = new ArrayCollection([
                 
                  {name : "mahesh : veerabathiran", nick : "mike", initial : "v", place : "chennai", city : "chennai"},
                  {name : "suresh : sundaram", nick : "mike", initial : "v", place : "chennai", city : "bang"},
                  {name : "vasanthi : bala sundaram", nick : "mike", initial : "v", place : "chennai", city : "mumb"},
                  {name : "krishna : prathab", nick : "mike", initial : "v", place : "chennai", city : "hydera"},
                  {name : "jotheesh : velayaudham", nick : "mike", initial : "v", place : "chennai", city : "sikkim"},
                  {name : "srivasa  : roa", nick : "mike", initial : "v", place : "chennai", city : "buttan"},
                  {name : "sonia : gandhi", nick : "Ms.Gandhi", initial : "v", place : "chennai", city : "lucknow"}
                 
                  ]);
                 
                       
              ]]>
          </mx:Script>
               
          <mx:DataGrid  headerStyleName="headStyle" headerHeight="50" width="800" paddingLeft="0" paddingRight="0" dataProvider="{ac}"  horizontalScrollPolicy="on">
              <mx:columns>
                  <mx:DataGridColumn dataField="name" width="300" />
                  <mx:DataGridColumn dataField="nick"  headerWordWrap="true" headerText="Name him"  width="300"/>
                  <mx:DataGridColumn dataField="place" width="300" />
                  <mx:DataGridColumn dataField="nick"  headerWordWrap="true" headerText="Name him"  width="300"/>
                  <mx:DataGridColumn dataField="place" width="300" />
                  <mx:DataGridColumn dataField="nick"  headerWordWrap="true" headerText="Name him"  width="300"/>
                  <mx:DataGridColumn dataField="place" width="300" />
                  <mx:DataGridColumn dataField="city" backgroundColor="red" width="300" />
              </mx:columns>
          </mx:DataGrid>
         
      </mx:Application>

       

      please give your suggestion about how to fix this issue as soon as possible. I am really looking for your solutions.