Extjs grid 单元格事件

celldblclick: function (view, td, cellIndex, record, tr, rowIndex, e, eOpts) {

//extjs 4.2下,有时出现,多次不连续双击某一个单元格时,取到的cellIndex不正确,解决办法如下:

cellIndex = td.cellIndex;
var columns = view.componentLayout.headerCt.columnManager.columns;
//console.log(columns);
for (var i = 0; i < columns.length; i++) {
console.log(columns[i].dataIndex);
};
var dataIndex = columns[cellIndex].dataIndex;
var dataIndex_method2 = view.getHeaderAtIndex(cellIndex).dataIndex;
console.log("被点击列的字段名 ", dataIndex, dataIndex_method2);
},

 

cellmouseup: function (grid, td, cellIndex, record, tr, rowIndex, e, eOpts) {
e.preventDefault();//阻止浏览器默认行为处理事件
//try {
if (lockCellmouseUP == true) {
return;
};
if (cellIndex > 2 && rowIndex > 2) { //
var key = grid.getHeaderAtIndex(cellIndex).dataIndex;
var btnNum = event.button;

if (btnNum == 0) {
record.set(key, "OK");//alert("您点击了鼠标右键!")
}
else if (btnNum == 2) {
record.set(key, "N/A");//alert("您点击了鼠标左键!")
}
else if (btnNum == 1) {
//alert("您点击了鼠标中键!");
}
else {
//alert("您点击了" + btnNum+ "号键,我不能确定它的名称。");
}
}; //grid.getView().refresh();
//} catch (e) {

//};
},

beforeedit: function (editor, e, eOpts) {
//只允许 第二行第三列以后的编辑
if (e.rowIdx == 1 && e.colIdx > 2) {
return true;
}
else {
return false;
}
},

转载于:https://www.cnblogs.com/hqyj/p/7017310.html

你可能感兴趣的:(Extjs grid 单元格事件)