Jquery 在进行内联编辑时,在jqgrid中获取文本框的默认值
我们可以使用以下方法获取普通html文本框的默认值:Jquery 在进行内联编辑时,在jqgrid中获取文本框的默认值,jquery,jqgrid,inline,edit,Jquery,Jqgrid,Inline,Edit,我们可以使用以下方法获取普通html文本框的默认值: $("#textboxId").prop("defaultValue"); 但是在jqgrid(内联编辑)中,编辑行时,如果选择文本框并选中defaultValue,则结果总是空的 我想在编辑模式下获取文本框的原始值,以检查文本框值是否真的更改 请帮忙。谢谢。您需要做的是使用jqGrid选项的onserow功能,当用户在内联编辑中单击行时,正确获取旧行数据,然后使用beforeSaveRow检查更改 下面是它的代码和链接 var lastS
$("#textboxId").prop("defaultValue");
但是在jqgrid(内联编辑)中,编辑行时,如果选择文本框并选中defaultValue,则结果总是空的
我想在编辑模式下获取文本框的原始值,以检查文本框值是否真的更改
请帮忙。谢谢。您需要做的是使用jqGrid选项的onserow功能,当用户在内联编辑中单击行时,正确获取旧行数据,然后使用beforeSaveRow检查更改 下面是它的代码和链接
var lastSel = 0;
var mydata = [
{id:"1", name: "abc",desc: "desc 11"},
{id:"2", name: "def",desc: "hello there"},
{id:"3", name: "xyz",desc: "desc 44"}
];
$("#list").jqGrid({
datatype: "local",
data: mydata,
height: "auto",
colModel :[
{name:'id',key:true, index:'idcustomers', width:55},
{name:'name', width:100,editable: true},
{name:'desc', width:100,editable: true}
],
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
sortname: 'idcustomers',
sortorder: 'asc',
viewrecords: true,
gridview: true,
caption: 'Customers',
cellsubmit: 'clientArray',
onSelectRow: function (id) {
var currentRow = $('#list').jqGrid("getRowData",id);
if (id && id !== lastSel) {
lastSel=id;
}
else
{
return;
}
jQuery('#list').editRow(id,
{
"keys": true,
oneditfunc: function () {
},
"successfunc": null,
"url": null,
"extraparam": {},
"aftersavefunc": null,
"errorfunc": null,
"afterrestorefunc": null,
"restoreAfterError": true,
"beforeSaveRow": function (options, rowid) {
// jqGrid calls its own SaveRow when the user hits 'Enter'. We need it to call ours.
// Note, the 'beforeSaveRow' is undocumented, but it gets invoked before jqGrid calls its own SaveRow method.
var newName = jQuery('#' + rowid + '_' + 'name').val();
var oldName = currentRow.name;
if(newName!=oldName)
{
alert('changed');
}
return true;
},
});
}
});
可能重复感谢您的回复,但不是。html-defaultValue属性和您提到的文章是相同的吗?不