2 Replies Latest reply on Jul 13, 2011 10:31 AM by Hadzel

    Advanced Grid change both of Values

    Hadzel

      I'm trying to create some advanceddatagrid that will have columns that are months and in each month 2 other columns ( children ), one with the available hours ( H ) and another with extra hours ( HE ).

       

      But the user can add and delete months, so can add and delete columns... what make this be a dynamical thing.

       

       

       

      And I tried this to create new column:

       

      var projectResourcesColumns:ArrayCollection = new ArrayCollection(dgAllocatedResources.groupedColumns);

       

      var dgc:AdvancedDataGridColumnGroup  = new AdvancedDataGridColumnGroup ();

      dgc.editable = true;

      dgc.sortable = false;

      dgc.headerText = nextMonth.Name;

       

      var columnHours : AdvancedDataGridColumn = new AdvancedDataGridColumn();

      columnHours.headerText = 'H';

      columnHours.dataField = nextMonth.Name;

      columnHours.editable = true;

      columnHours.sortable = false;

      columnHours.labelFunction = getHoursAvailabilityMonth;

       

      var columnExtra : AdvancedDataGridColumn = new AdvancedDataGridColumn();

      columnExtra.headerText = 'HE';

      columnExtra.dataField = nextMonth.Name;

      columnExtra.editable = true;

      columnExtra.sortable = false;

      columnExtra.itemEditor = textHERestrict;

      columnExtra.showDataTips = true;

      columnExtra.labelFunction = getHoursExtraAvailabilityMonth;

       

      dgc.children.push(columnHours, columnExtra);

       

      projectResourcesColumns.addItem(dgc);

       

      dgAllocatedResources.groupedColumns = projectResourcesColumns.toArray();

      .

      .

      .

       

      private function getHoursAvailabilityMonth (item:Object, column:AdvancedDataGridColumn) : String

      {

      return (item as DynamicProjectResourceGrid)[column.dataField].hasOwnProperty("H") ? (item as DynamicProjectResourceGrid)[column.dataField].H + "" : (item as DynamicProjectResourceGrid)[column.dataField].toString();

      }

       

      private function getExtraHoursAvailabilityMonth (item:Object, column:AdvancedDataGridColumn) : String

      {

      return (item as DynamicProjectResourceGrid)[column.dataField].hasOwnProperty("HE") ? (item as DynamicProjectResourceGrid)[column.dataField].HE + "" : (item as DynamicProjectResourceGrid)[column.dataField].toString();

      }

       

       

       

       

       

       

       

       

       

      And this works! But when I changed the text of the TextInput of the Hours Column or Extra Hours Column... Both of column get the same value.

       

      Ex :

       

      |     08/11      |

      ------------------

      |  H     /   HE |

      ------------------

      |  10    /    10 |

       

       

      Thanks for attention. Sorry for bad english!