5 Replies Latest reply on May 14, 2009 10:42 AM by Flex harUI

    ArayCollection refresh() problem.

    kage0002 Level 1

      Hi,

      I have a problem to see my data and I think its a refresh() problem.

      My application has 2 Tabs. The first one has one Datagrid(dg) and the second two(dg1 dg2). When I click on one Item of the first Tab I switch to the second Tab.

      When I switch to the second Tab a "show" Eventlistener triggers a function that activates the first Item of the first DataGrid (Tab2) and I can see on the second DataGrid details of my selected Item. Thats how it should work and does. But when I go back to the first Tab and then switch back to the second Tab2 the DataGrid doesn´t show the detailinformation of the selected Item anymore. Does anyone know why? Why does it just works the first time?

      Here some code for a better understanding of my Problem:

       

       

       

       

       

       

       

       

       

       

      Tab2:

       

      <mx:VBox show="showTab()">

      //Tab2DataGrid1

       

       

       

      <mx:DataGrid

       

      id="dg1_tab2" dataProvider="{data2Provider}" itemClick="onDgItemClick(event)" change="onDgItemClick(event)" >

       

       

       

      //Tab2DataGrid2

       

       

       

       

       

      <mx:DataGrid

       

      id="dg2_tab2 dataProvider="{dataProvider}"/>

      </mx:Vbox>

       

       

      function that is triggered by the show eventlistener:

       

      private

       

       

       

       

      function showTab():void

      {

       

       

       

       

      //Select the first Item of Tab2 FirstDataGrid

      if (dg_tab1.selectedIndex >= 0){

       

       

      dg1_tab2.selectedIndex = 0;

      }

      //DataProvider for the Details of this selected Item

       

      var item = dg1_tab2.selectedItem;

       

       

      dataProvider =

      new ArrayCollection(item.positions);

       

       

      dataProvider.refresh();

      .....