2 Replies Latest reply on Aug 15, 2007 10:19 PM by P Steven

    Using label function for dynamically created datagrid

    P Steven Level 1
      I am creating a data grid dynamically based on the data returned from a script call from the server.

      I know that some of my data will be nested so I need to use a label function to ensure this data is displayed by the datagrid

      All the examples of using a label function that I can find seem to have the columns hard coded like in the following example

      <mx:DataGridColumn headerText="Name" dataField="menuName"/>
      <mx:DataGridColumn headerText="Vegetarian" labelFunction="displayVegetarian"/>
      <mx:DataGridColumn headerText="Peanuts" labelFunction="displayPeanuts"/>
      <mx:DataGridColumn headerText="Quantity" labelFunction="displayQuantity"/>
      <mx:DataGridColumn headerText="Price" labelFunction="displayPrice"/>
      <mx:DataGridColumn headerText="Line Total" labelFunction="displayLineTotal"/>

      I am however creating my data grid columns dynamically so cannot use the <mx:DataGridColumn way of doing this

      My code works like follows

      for (var i:uint=0; i<xlColumns.length(); i++) {

      dgc = new DataGridColumn();
      dgc.dataField = "componentScores.ScoreValue" <----- THIS NEEDS TO USE A LABEL FUNCTION
      dgc.headerText = _qualificationSummaryScreenData.getComponentTitle(componentIndex);


      I have highlighted above where I need to use a label function. I really hope someone can help me out here as I am currently taking one step forward and two steps backwards with Flex at the moment and already serveral weeks behind schedule on this project.

      Many thanks