DevExtreme DataGrid onRowDblClick

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);

我做到了这一点,工作得很好(我遵循这个答案)

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;
        }
    });
链接地址: http://www.djcxy.com/p/31040.html

上一篇: 角2为什么星号(*)

下一篇: DevExtreme DataGrid onRowDblClick