5 Replies Latest reply on Nov 11, 2011 7:04 AM by Amy Blankenship

    Strange Behaviour on DataGrid with ArrayCollection as DataProvider

    Z4g0s Level 1

      I have a Datagrid with an ArrayCollection as DataProvider, the arrayCollection is partially generated by a remoteObject call, the dataprovider seems to works at least until I try to edit the field...



      By the RemoteObject I only receive an ArrayCollection with the field `ip`, but the datagrid looks for the fields ip, check and save...

      If I add/edit this new field it works, but only under particular condition





      The DataGrid:



       <s:DataGrid id="datagrid" left="10" right="10" top="136" 
             dataProvider="{listaIPCheck}" bottom="10" requestedRowCount="4">
                           <s:GridColumn dataField="ip" headerText="Asset"/>
                           <s:GridColumn dataField="check" headerText="Inventory"/>
                           <s:GridColumn dataField="save" headerText="Salvataggio"/>


      The Script:




         [Bindable]private var listaIPCheck:ArrayCollection; 
          private function ro_resultHandler(event:Event=null):void
            listaIPCheck = new ArrayCollection();
            listaIPCheck = ro.getListUpdate.lastResult;
            heap = 0; 
            // Read Below {POINT #1}
          private function init3():void
           // Read Below {POINT #2}
           if (heap<listaIPCheck.length)
              // omitted the initialization of the process p
              p.addEventListener(NativeProcessExitEvent.EXIT, onExit);
          private function onExit(e:NativeProcessExitEvent):void { 
              // Read below {POINT #3}

      Here is my code, now as you can see there are 3 line where I wrote to read below...

      Let's assume to put this simple `for` instead of the commented line (once at a time)



          for (var k:Number=0;k<listaIPCheck.length;k++)
            listaIPCheck.getItemAt(k).check = "checkVal";
            listaIPCheck.getItemAt(k).save = "saveVal";


      This code always work in the 3 points, so at the end of the call the ArrayCollection is always filled with the new values, but the datagrid refresh the items only in POINT #1 and POINT #2

      Why not in Point #3???