Hi Xander,
Query: “is there anyway to hook into 1) a single click and 2) a double click event for the ejGrid rows? I want my user to click (or double click) a row to pop up with a modal dialog/window.”
Yes, the ejGrid have recordClick and recordDoubleClick events which will trigger at single click and double click of the grid rows respectively.
The recordClick and recordDoubleClick events will be initialized in the grid as follow.
|
$("#Grid").ejGrid({ dataSource: data, recordClick: "selected", columns: . . . . });
$("#Grid").ejGrid({ dataSource: data, recordDoubleClick: "selected", columns: . . . . . });
|
Please refer the following table for arguments passed to the args of the callback by the recordClick and recordDoubleClick events.
|
Name |
Description |
|
recordDoubleClick |
Trigger when double click on grid record. |
|
$("#Grid").ejGrid({recordDoubleClick: function (args) {
// args.cancel - Returns the cancel option value. // args.model - Returns the grid model. // args.type - Returns the name of the event. //args.currentRowIndex -Return the index of the row clicked. //args.currentRow -Return the target row. //args.currentData -Return the data of the row. }});
|
|
|
recordClick |
Trigger when single click on grid record. |
|
$("#Grid").ejGrid({recordClick: function (args) {
// args.cancel - Returns the cancel option value. // args.model - Returns the grid model. // args.type - Returns the name of the event. //args.currentRowIndex -Return the index of the row clicked. //args.currentRow -Return the target row. //args.currentData -Return the data of the row. }});
|
|
The recordClick and recordDoubleClick events are included in our last service pack release and so we suggest you to upgrade your Essential Javascript package with the service pack available in the following link.
Service Pack: http://www.syncfusion.com/downloads/jsservicepacks .
For your convenience we have created a simple sample and please find the attached sample.
Please let us know if you require further assistance.
Regards,
Madhu Sudhanan. P
Hi Xander,
We have provided the recordClick and recordDoubleClick events support only in Essential Javascript version 11.4.0.26 and not in 11.2.
Please let us know if we misunderstood your requirement and provide some more information about the issue that you have faced after upgraded to the new version, so that it will be helpful for us to analyze about the issue and update the response as early as possible.
Regards,
Madhu Sudhanan. P
Hi Xander,
We regret for the inconvenience caused.
Mistakenly the recordClick and recordDoubleClick events feature was not included in the last service pack release. The previously provided ej.widgets.all.min.js file has been taken from our Current development location and also the header version is mentioned as 11.2 instead of 11.4. Please upgrade to the 11.4 version and use the file ej.widgets.all.min.js that has been already provided in the attached sample.
The recordClick and recordDoubleClick are working properly while using the provided ej.widgets.all.min.js file. We will include this feature in our upcoming Volume 1, 2014 release on the month of April.
Please let us know if you have any queries.
Regards,
Maithiliy K
|
var grid= new ej.grids.Grid({
dataSource: orderData.slice(0,5),
columns: [
. . .
],
height: 210,
});
grid.appendTo('#Grid');
grid.recordDoubleClick = (args) => {
var a = e.rowIndex;
alert(‘Double Clicked rowIndex: ’+a);
}
grid.element.addEventListener('click',(e)=>{
var cell = ej.base.closest(e.target, 'td');
if (cell && ej.base.closest(cell, '.e-row')) {
var data = grid.getRowInfo(e.target);
alert(data.rowIndex); }
});
|
|
var grid= new ej.grids.Grid({
dataSource: data.slice(0,5),
columns: [
...
],
height: 210,
rowSelected: singleClick
});
grid.appendTo('#Grid');
...
function singleClick(args){ //for Single click
alert(args.rowIndex);
}
grid.element.addEventListener('dblclick',(e)=>{ //for double click
var cell = ej.base.closest(e.target, 'td');
if (cell && ej.base.closest(cell, '.e-row')) {
// get your required values
var data = grid.getRowInfo(e.target);
alert(data.rowIndex);
}
}); |
|
var grid= new ej.grids.Grid({
columns: [
...
],
height: 210,
recordDoubleClick: doubleClick
});
grid.appendTo('#Grid');
grid.element.addEventListener('click',(e)=>{ //Single click event
var cell = ej.base.closest(e.target, 'td');
if (cell && ej.base.closest(cell, '.e-row')) {
// get your required values
var data = grid.getRowInfo(e.target);
console.log("Single "+ data.rowIndex);
}
});
function doubleClick(args){ //recordDoubleClick event
console.log("double "+ args.rowIndex);
}
function loadData(args){
var grid=document.getElementById("Grid").ej2_instances[0];
var gridIdeasListData = data;
grid.dataSource = gridIdeasListData; //load datasource dynamically to the grid
grid.refresh();
} |