Something like this?

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";

    xmlns:s="library://ns.adobe.com/flex/spark"

    xmlns:mx="library://ns.adobe.com/flex/mx"

    xmlns:view="com.nexage.common.view.nexWizard.view.*"

    xmlns:pages="com.nexage.common.view.nexWizard.sampleWizard.pages.*"

    xmlns:components="com.nexage.common.view.nexWizard.view.components.*"

    xmlns:sampleWizard="com.nexage.common.view.nexWizard.sampleWizard.*"

    width="100%"

    height="100%"

    creationComplete="onCC()"



    >

  <fx:Declarations>

 <!-- Place non-visual elements (e.g., services, value objects) here -->

</fx:Declarations>

 <fx:Style source="wizardStyles.css" />

 <fx:Script>

 <![CDATA[

 import com.nexage.common.models.Employee;

   import mx.collections.ArrayCollection;

   private function onCC():void

 {

  setEmployees()

 }


  [Bindable]

 private var employees:ArrayCollection = new ArrayCollection();

 private var firstNamesArr:Array = ['Mohamed', 'Youssef', 'Ahmed', 'Mahmoud',
'Mustafa'];

 private var lastNamesArr:Array = ['George', 'John', 'Mina', 'Beshoi',
'Kirollos', 'Mark', 'Fadi', 'Habib'];

   private function setEmployees():void

 {

  for( var i:int = 0; i<firstNamesArr.length; i++ )

  {

  var empl:Employee = new Employee( firstNamesArr[i], lastNamesArr[i] );

  employees.addItem( empl );

  }

 }

   ]]>

</fx:Script>

 <s:layout>

 <s:VerticalLayout />

</s:layout>

 <s:Spacer height="50" />

 <s:Button label="hide/show first names"

   click="{firstNameCol.visible = !firstNameCol.visible}" />

  <s:DataGrid width="50%"

  horizontalCenter="0"

  verticalCenter="0"

  dataProvider="{employees}">

 <s:columns>

 <s:ArrayList>

  <s:GridColumn id="firstNameCol"

     headerText="First Name"

     dataField="firstName" />

    <s:GridColumn id="lastNameCol"

     headerText="Last Name"

     dataField="lastName" />

 </s:ArrayList>

 </s:columns>

</s:DataGrid>

   </s:Application>

Doug
On Jan 14, 2013 6:15 PM, "Oleg Konovalov" <[email protected]> wrote:

> **
>
>
> Hi,
>
> I am trying to create dynamic DataGrid,
> which shows columns only if it contains data
> returned by query (it has 10+ columns, so not easy to calculate sizes)..
> I read a lot of posts on the net, tried minWidth, ResizeMode, etc.
>
> Nothing really useful which works.
> In most cases it created very narrow columns except the last one - super
> wide.
>
> Please help!
>
> (using Flex4 AdvancedDataGrid)
>
> --
> Thank you in advance,
> Oleg.
>
>  
>

Reply via email to