JqGrid:我能知道在OnSetrow中单击了哪个操作按钮吗?
我有一个网格。第一列是每行的复选框。第二列每行有两个操作按钮:编辑和删除。当单击编辑按钮或删除按钮时,我想知道单击了哪个按钮JqGrid:我能知道在OnSetrow中单击了哪个操作按钮吗?,jqgrid,Jqgrid,我有一个网格。第一列是每行的复选框。第二列每行有两个操作按钮:编辑和删除。当单击编辑按钮或删除按钮时,我想知道单击了哪个按钮 $(grid_selector).jqGrid({ url:'loaddata.php', datatype: "json", refresh: true, height: 250, colNames:[' ', 'ID','Last Sales','Name', 'Stock', 'Ship via','Notes'], colModel:[ {
$(grid_selector).jqGrid({
url:'loaddata.php',
datatype: "json",
refresh: true,
height: 250,
colNames:[' ', 'ID','Last Sales','Name', 'Stock', 'Ship via','Notes'],
colModel:[
{
name:'myac',index:'', width:90, fixed:true, sortable:false, resize:false,
formatter:'actions',
formatoptions:{
keys:true,
delOptions: {
recreateForm: true,
beforeShowForm: beforeDeleteCallback,
url: "delete.php",
mtype: 'POST',
onclickSubmit: function(options, rowid) {
var rowData = $(this).jqGrid("getRowData", rowid);
options.url += "?" + $.param({
id: rowData.id
});
},
editOptions:{
recreateForm: true,
beforeShowForm:beforeEditCallback
}
}
},
},
{ name:'id',index:'id', width:100, sorttype:"int", editable: false, hidden: false},
{ name:'sdate',index:'sdate',width:90, editable:true, sorttype:"date",unformat: pickDate},
{ name:'name',index:'name', width:150,editable: true,editoptions:{size:"20",maxlength:"30"}},
{ name:'stock',index:'stock', width:70, editable: true,edittype:"checkbox",editoptions: {value:"Yes:No"},unformat: aceSwitch},
{ name:'ship',index:'ship', width:90, editable: true,edittype:"select",editoptions:{value:"FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX"}},
{ name:'note',index:'note', width:150, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"10"}}
],
....
onSelectRow: function(id){
jQuery(grid_selector).restoreRow(id);
$('#jSaveButton_' + id).hide();
$('#jCancelButton_' + id).hide();
$('#jEditButton_' + id).show();
$('#jDeleteButton_' + id).show();
// the code above is for disabling inline editing for any click on anywhere of a row
// but I still want to invoke the edit form when the edit button is clicked
// via $(grid_selector).editGridRow(id, {} );
?????? Can I know know which action button is clicked?
},
....
});
请注意我当前OnSetrow()中的注释:
谢谢和问候 我不确定我是否了解您正在实施的完整场景。因此,我只想回答您的主要问题:如何检测
onsetrow
回调的内部,该回调是因为单击了删除按钮而调用的
您可以使用onsetrow
的三维参数。相应的代码可能与以下内容有关:
onsetrow:功能(rowid、status、e){
var$div=$(e.target).closest(“.ui pg div”);
if($div.hasClass(“ui内联del”)&&$div.attr(“id”)==“jdeletbutton”+rowid){
警报(“已单击删除按钮”);
}//else if($div.hasClass(“ui内联编辑”)&&$div.attr(“id”)==“绝地按钮”+rowid){
//警报(“单击了编辑按钮”);
//}
}
谢谢您的帮助。这满足了我的需要。我希望我上面所说的完全禁用内联编辑,但在单击编辑按钮时仍然允许表单编辑的方法并不愚蠢。谢谢
// the code above is for disabling inline editing for any click on anywhere of a row
// but I still want to invoke the edit form when the edit button is clicked
// via $(grid_selector).editGridRow(id, {} );