1

I want to implement an onRowDblClick event for the DevExtreme DataGrid. I need this Event for multiple grids so I would like to implement this for the DataGrid for general.

I was thinking about overriding the onClick action and check for a double click or extend the DataGrid with an onRowDblClick Action but i have no idea how to implement this.

Please advise a way to do this functionality.


OK, finally I implemented an addRowDblClick function which looks like this:

var clickTimer, lastRowClickedId;
function addRowDblClick(id, dblClickFunc) {
  $("#" + id).dxDataGrid({
    onRowClick: function (e) {
      //OBTAIN YOUR GRID DATA HERE
      var grid = $("#" + id).dxDataGrid('instance');
      var rows = grid.getSelectedRowsData();

      if (clickTimer && lastRowCLickedId === e.rowIndex) {
        clearTimeout(clickTimer);
        clickTimer = null;
        lastRowCLickedId = e.rowIndex;
        //YOUR DOUBLE CLICK EVENT HERE
        if (typeof dblClickFunc == 'function')
          dblClickFunc();
      } else {
        clickTimer = setTimeout(function () { }, 250);
      }
      lastRowCLickedId = e.rowIndex;
    }
  });
}

And at the DataGrid I called an function OnContentReady where I call this function with the Id and the function I want to call when I double click.

addRowDblClick('dxDataGrid', showDetail);
Ich
  • 226
  • 3
  • 13

2 Answers2

1

I that work with this :

$("#grdMain").dxDataGrid({
   ....
   onRowPrepared:function(event){
      $(event.rowElement).on('dblclick', function(){
         console.log('row dblclicked');
      }).on('remove', function(){
          //on remove event in jquery ui libraries or 
          // https://stackoverflow.com/questions/29255801/jquery-on-remove-not-working-parent-node-fire-empty
          $(this).off('dblclick remove');
     })
  }            
})
Haydar C.
  • 742
  • 12
  • 24
0

I did this and worked pretty well (I followed this answer)

var clickTimer, lastRowCLickedId;

    $("#grdMain").dxDataGrid({            
        ...
        onRowClick: function (e) {               
            //OBTAIN YOUR GRID DATA HERE
              var grid = $("#grdMain").dxDataGrid('instance');
              var rows = grid.getSelectedRowsData();

            if (clickTimer && lastRowCLickedId === e.rowIndex) {
                clearTimeout(clickTimer);
                clickTimer = null;
                lastRowCLickedId = e.rowIndex;
                //YOUR DOUBLE CLICK EVENT HERE
                alert('double clicked!');
            } else {
                clickTimer = setTimeout(function () { }, 250);
            }

            lastRowCLickedId = e.rowIndex;
        }
    });
Victor Hugo Terceros
  • 2,969
  • 3
  • 18
  • 31