我在jqGrid中有内联编辑的问题。我想有两个编辑方法:
- 首先-编辑通过双击行(它的工作),我可以'保存'或'取消',只有通过键'enter'和'escape'。我应该怎么做,如果我想有一个活动的图标"保存"one_answers"取消"?其不活跃。
- 其次-(更重要的),编辑通过选择行和点击图标"编辑"(它的作品太),我可以"保存"或"取消"只能通过图标。我应该怎么做,如果我想使用键'enter'和'escape'来保存和取消?
我只对内联编辑感兴趣。我在这里读到关于编辑"icon":When the button is clicked a editRow method is executed
。我有功能,但它不是自动打开后,我按下图标"编辑"。它应该覆盖默认函数吗?
$(function(){
var rowid;
$("#list").jqGrid('editRow',rowid,
{
keys : true,
oneditfunc: function() {
alert ("edited");
}
});
});
JqGrid代码:
$(function(){
$("#list").jqGrid({
url:'<?php echo $this->baseUrl('/jq-grid/view'); ?>',
datatype: 'xml',
mtype: 'GET',
colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],
colModel :[
{name:'invid', index:'invid', width:55, sorttype:'int', hidden:false,
editable:true, key: true,
editrules:{ required:false, integer:true, edithidden:true} },
{name:'invdate', index:'invdate', width:90,
editable:true,
editrules:{ date:true} },
{name:'amount', index:'amount', width:80, align:'right',
editable:true,
editoptions:{readonly:false} },
{name:'tax', index:'tax', width:80, align:'right',
editable:false,
editrules:{ edithidden:true} },
{name:'total', index:'total', width:80, align:'right',
editable:false},
{name:'note', index:'note', width:150, align:'right', sortable:false,
editable:false}
],
rowNum:5,
rowList:[10,15,20,30],
rowTotal: 2000, //maksimum
loadonce: true,
pager: '#pager',
viewrecords: true,
sortname: 'invid',
sortorder: 'asc', //'desc'
gridview: true,
height: '100%',
width: '700',
ondblClickRow: function(id){
//jQuery('#list').editRow(id); //, true
jQuery('#list').jqGrid('editRow',id,true);
},
editurl: '<?php echo $this->baseUrl('/jq-grid/edit'); ?>'
//hidegrid:false,
//hiddengrid:true,
//caption: 'Grid'
});
$(function(){
$("#list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
});
$(function(){
$("#list").jqGrid('navGrid',"#pager",{edit:false,add:false,del:true}); //,search:false,refresh:false
});
$(function(){
$("#list").jqGrid('inlineNav',"#pager",{
save:true,
edit:true,
addParams: {addRowParams: {}}
})
});
下面的字段代码将允许内联编辑并显示保存和取消图标
{ name: "action", formatter: 'actions', index:"action", align: "left",sortable: false, editable: false,
formatoptions:{
keys: true,
editbutton: true,
delbutton: true,
editOptions: {
closeOnEscape: true,
closeAfterAdd: true,
viewPagerButtons: false,
closeAfterEdit: true,
afterSubmit: function (response, postdata) {
var r = $.parseJSON(response.responseText);
return [r.success, r.Description, null];
}
},
deleteOptions: {
closeOnEscape: true,
closeAfterAdd: true,
viewPagerButtons: false,
closeAfterDelete: true,
afterSubmit: function (response, postdata) {
var r = $.parseJSON(response.responseText);
return [r.success, r.Description, null];
}
}
}
},