4 Replies Latest reply on Mar 4, 2008 1:23 PM by nephish

    how to dynamically add a column to data grid

    nephish
      Hey there all. Pardon me, i am very new at this.
      I am using a data grid to display some values parsed out of an xml file.
      The app needs 5 columns, no problem, however, if a certain value is present in the xml, i need to add another column.
      if i have a var set like
      var gps_present that is a string, and if the value == 'yes' add a column to my datagrid ?

      <mx:DataGrid id="summary_grid" x="10" y="15" width="500" height="434"
      dataProvider="{summary.lastResult.phones.phone}">
      <mx:columns>
      <mx:DataGridColumn headerText="phonenumber" dataField="phonenumber" width="3" />
      <mx:DataGridColumn headerText="inc_java" dataField="inc_java" width="3" />
      <mx:DataGridColumn headerText="inc_sms" dataField="inc_sms" width="3" />
      some logic here if inc_gps == 'y'
      <mx:DataGridColumn headerText="inc_gps" dataField="gps" width="3" />
      </mx:columns>
      </mx:DataGrid>


      thanks for any tips on this.