1 Reply Latest reply on Oct 29, 2007 9:38 AM by cxf02

    Datagrid questions

    cxf02 Level 1
      I have a datagrid whereI would like to select multiple rows and then copy the rows into another object, manipulate them and the shove them into antother data grid. The business process is to take a shipment with a single start and end point (a single leg, or route, if you will) and then introduce a hub into the route, thus breaking a single-route into a two-leg-route, a two-leg-route into a three-leg-route, and so on...

      I found a method listed as: copySelectedItems(useDataField:Boolean = true):Array which the help says "Makes a copy of the selected items in the order they were selected.", and it belongs to a ListBase which is a parent class. Now, correct me if I'm wrong, but in Java I wouldn't have a problem accessing a protected member of a parent class. That doesn't seem to work in this case. I have tried to use the method like this:

      private function setSelection(event:Event):void {
      var list:Array = event.currentTarget.copySelecteditems(true);
      var list2:Array = list;
      }

      The exception is this:

      ReferenceError: Error #1069: Property copySelecteditems not found on mx.controls.DataGrid and there is no default value.
      at Pooling/setSelection()[F:\Eclipse6Workspaces\Services\Pooling\src\Pooling.mxml:27]
      at Pooling/__shipGrid_itemClick()[F:\Eclipse6Workspaces\Services\Pooling\src\Pooling.mxml:49 ]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::UIComponent/dispatchEvent()[E:\dev\flex_3_beta2\sdk\frameworks\projects\framewor k\src\mx\core\UIComponent.as:8915]
      at mx.controls.listClasses::ListBase/mouseClickHandler()[E:\dev\flex_3_beta2\sdk\frameworks\ projects\framework\src\mx\controls\listClasses\ListBase.as:8661]

      I'm not sure what is the root of this issue, or if it's just a matter of me not understanding actionScript. I can make the process work by iterating through the selected items, and that's not too bad, but it would be great if I could make the shortcut method work.

      I appreciate everyone's help, thanks...
        • 1. Re: Datagrid questions
          cxf02 Level 1
          Okay, I'll answer my own question. The selectedItems property of the dataGrid returns an array.
          var list:Array = event.currentTarget.selectedItems;

          ...does exactly what I need.

          I don't feel too smart after this one!

          Cheers,