0 Replies Latest reply on Dec 1, 2010 10:37 PM by vishnu_aol

    Using DoubleClick and DragManager together in Flex AdvancedDataGrid

    vishnu_aol

      Hi All,

       

      I have encountered a problem while implementing a DOUBLE_CLICK to the item in an AdvancedDataGrid.

       

      Scenario:

       

      I have an AdvancedDataGrid called aGrid. I need to implement DOUBLE_CLICK to the items in an AdvancedDataGrid.

      I have implemented drag functionality in the AdvancedDataGrid.

       

      [BINDABLE]
      private var _gridColumns:Array = new Array();

       

      private var aGrid:AdvancedDataGrid = new AdvancedDataGrid();

      I use the following code inside the constructor function

       

      this.aGrid.columns = this._gridColumns;

      this.aGrid.doubleClickEnabled=true;

      this.aGrid.selectionMode="singleCell"
      this.aGrid.dragEnabled = true;


      this.aGrid.addEventListener(ListEvent.ITEM_DOUBLE_CLICK,testDoubleClick);
      this.aGrid.addEventListener(MouseEvent.MOUSE_DOWN,dragIt);

       

      this.addColumn(" ","@name"); /*Used to add Columns in the Datagrid*/

       

      //Also used the following functions

       

      private function testDoubleClick(e:ListEvent):void

      {           
                  var item:Object = AdvancedDataGrid(e.currentTarget).selectedItem;

       

                  Alert.show(ObjectUtil.toString(item));

      }

       

      private function addColumn(title:String, dataField:String, editable:Boolean = false):void
              {
                  var newColumn:AdvancedDataGridColumn = new AdvancedDataGridColumn(title);
                  newColumn.dataField = dataField;
                  newColumn.editable = editable;
                  newColumn.rendererIsEditor = editable;

       

                  this._gridColumns.push(newColumn);
              }

       

      private function dragIt(event:MouseEvent):void
              {         
                  var adDataGrid:AdvancedDataGrid = event.currentTarget as AdvancedDataGrid;


                  if(adDataGrid.isItemSelected(adDataGrid.selectedItem))
                  {
                      var di:* = event.currentTarget;
                      var item:Label = new Label();
                      item.text = adDataGrid.selectedItem.@name;   
                      item.setStyle('paddingTop',adDataGrid.mouseY-5);
                      item.setStyle('paddingLeft',adDataGrid.mouseX-5);
                     
                      var ds:DragSource = new DragSource();
                      ds.addData(adDataGrid.selectedItem.@objecttype, 'type');
                      ds.addData(adDataGrid.selectedItem, 'data');
                      ds.addData(this, 'externalData');

       

                      DragManager.doDrag(di, ds, event, item);
                  }
              }

       

       

      Issue:

       

      There is a conflict occuring between the drag and the double click. If I try this code the drag functionality is not getting worked.

       

      The result needed is both the Double Click and drag functionality should work fine.

       

      Please help to resolve this issue. Awaiting reply.