jqGrid-保存内联编辑不起作用
jqGrid - Saving an Inline Edit not working
我有一个jqGrid,其中有一个使用内联添加/编辑功能的用户列表。由于某种原因,当调用saveEdit
函数时,我无法让jqGrid保存我所做的编辑,但如果我按enter
键,数据将保存。如果我注释掉jqGrid的inlineNav
行,那么一切都会按预期进行。
需要澄清的是,当我的saveEdit
函数运行时,从未向服务器发送任何请求。当我按下回车键时,会向服务器发送一个请求。知道发生了什么事吗?
这是我的代码:
var editParams = {
afterSubmit: processResponse,
successfunc: function(response) {
var processed = processResponse(response);
if(processed[0] !== true) {
$.jgrid.info_dialog($.jgrid.errors.errcap, processed[1], $.jgrid.edit.bClose);
}
return processed[0];
},
bottominfo: 'Fields marked with an (*) are required',
keys: true
};
$.extend($.jgrid.edit, editParams);
$('#grid')
.jqGrid({
datatype: 'json',
colNames: ['User ID', 'First Name', 'Last Name', 'Email'],
colModel: [
{name: 'usr_id', jsonmap: 'usr_id', width: 75, editable: true, editrules: {required: true}, formoptions: {elmprefix: '(*) '}},
{name: 'usr_fname', jsonmap: 'usr_fname', width: 75, editable: true, editrules: {required: true}, formoptions: {elmprefix: '(*) '}},
{name: 'usr_lname', jsonmap: 'usr_lname', width: 75, editable: true, editrules: {required: true}, formoptions: {elmprefix: '(*) '}},
{name: 'usr_email', jsonmap: 'usr_email', width: 125, editable: true, editrules: {required: true}, formoptions: {elmprefix: '(*) '}}
],
grouping: true,
shrinkToFit: false,
height: 200,
width: 800,
rowNum: 20,
rowList: [10, 20, 30, 40, 50, 100],
repeatitems: false,
ignoreCase: true,
jsonReader: { repeatitems: false, id: 'usr_id'},
pager: '#grid_pager',
url: 'dataurl.php',
editurl: 'editurl.php',
ondblClickRow: inlineEdit,
onSelectRow: saveEdit
})
.jqGrid('navGrid', '#users_pager', {add: false, edit: false, del: false, refresh: false, search: false})
.jqGrid('inlineNav', '#users_pager', {edit: false, save: false, cancel: false}); //If I comment out this line, everything works perfectly
var lastSel;
/* Start editing the row */
function inlineEdit(id, iRow, iCol) {
$(this).jqGrid('editRow', id, true, function() { focusRow(id, iCol, this); });
}
function focusRow(id, iCol, table) {
var ele = document.getElementById(id + '_' + table.p.colModel[iCol].name),
length = ele.value.length;
ele.focus();
if(ele.setSelectionRange) { //IE
ele.setSelectionRange(length, length);
}
else if(ele.createTextRange) {
var range = ele.createTextRange();
range.collapse(true);
range.moveEnd('character', length);
range.moveStart('character', start);
range.select();
}
}
function saveEdit(id) {
if(id && id != $(this).data('lastSel')) {
/* Save the last selected row before changing it */
$(this).jqGrid('saveRow', $(this).data('lastSel'), editParams);
$(this).data('lastSel', id);
}
$(this).data('lastSel', id);
}
提前感谢任何帮助我的人。
好吧,伙计,你无论如何都没有使用inlineNav,你为什么要把它放在那里?第二,当你按下回车键时,它不会调用你的saveEdit函数,默认情况下,功能只是这样。
我看到您正在将记录保存在onSelectRow属性上,当按enter键时,在内联编辑后,将不会调用它。你可以让你的钥匙:假的。按下回车键时不会触发对服务器的请求。
相关文章:
- 编辑不起作用的表单的特定行和重置特定字段
- `ie9`-contenteditable false在父级可编辑时不起作用
- 在内联编辑的情况下,Knockout绑定不起作用
- jqGrid-保存内联编辑不起作用
- Node.js应用程序中的编辑不起作用
- 所见即所得内容中的撤消和重做SWT中的可编辑内容;不起作用
- CKEditor编辑器.resize()在jQuery中不起作用
- 编辑器导出的json文件不起作用
- 在我的项目中,添加、删除和编辑功能不起作用
- 禁用编辑和删除按钮在IE9中不起作用,但在IE11中起作用
- 单击动态创建的编辑按钮不起作用
- Emberjs 车把内容绑定编辑字段不起作用
- AngularJS编辑记录行为不起作用
- 箭头键在内容中不起作用可编辑
- 如何在选择框中设置只读 false,当选中复选框时,它将是可编辑的.在我的jquery代码中,禁用不起作用
- 数据表可编辑插件在数据表中动态添加行后不起作用
- 添加,编辑,删除不起作用
- AngularJS使用模板进行内联编辑不起作用
- 剑道网格内的剑道组合框编辑不起作用
- 本地存储编辑不起作用