[英]uncheck the checkbox upon saving a row
I am using a jqgrid and whenever I check a check box the row is editable but I have 2 issues: 我正在使用jqgrid,每当我选中复选框时,该行都是可编辑的,但是有2个问题:
After editing the row the checkbox is still checked but I want it to be unchecked upon entering enter and saving the row .. 编辑完该行后,该复选框仍处于选中状态,但我希望在输入Enter并保存该行时取消选中它。
I want to click on one checkbox at a time 我想一次单击一个复选框
here is my code 这是我的代码
dataGrid.prototype = {
display: function() {
var self = this;
var html = [];
var check = 0;
var lastSelection;
html.push("<table id='" + this.id + "" + "'class='table'>\n</table>");
html.push("<div id='pagger_" + this.id + "'></div>");
$('body').append(html.join(""));
$("#" + this.id).jqGrid({
url: "index.jsp",
styleUI: 'Bootstrap',
.....
loadComplete: function() {
$("#" + this.id).on("click", "input[type=checkbox]", function(e) {
var $this = $(this); //this is the checkbox
var rowid = $this.parents('tr').attr('id');
self.editRow(rowid);
});
}
});
},
.....
editRow: function(id) {
var lastSelection;
if (id && id !== lastSelection) {
$("#" + this.id).jqGrid('restoreRow', lastSelection);
$("#" + this.id).jqGrid('editRow', id, {
keys: true,
focusField: 1
});
lastSelection = id;
}
}
};
If you have only (1) checkbox, you can put something like $('#your_checkbox').prop('checked',false);
如果只有(1)个复选框,则可以放置类似
$('#your_checkbox').prop('checked',false);
after the save function. 保存功能之后。 Or if you have multiple checkboxes, you can put something like this
$('#your_form input').prop('checked',false);
或者,如果您有多个复选框,则可以
$('#your_form input').prop('checked',false);
类似$('#your_form input').prop('checked',false);
. 。
如果要取消选中单个复选框$(“#checkbox_Id”)。attr(“ checked”,false),则在“保存”按钮中单击类似的放置。如果要使用多个复选框,请使用复选框类别取消选中所有复选框$(“ .checkbox_class“)。attr(” checked“,false)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.