问题
My requirement is, If I click a row in jqgrid with inline edit feature. In edit mode, I don't want the existing cell content to be present. Instead the cell contents should be blank, so that user enters anything, that gets saved .
I am able to access cell contents using selected Id, but how do I clear it and set it in the edit mode.
回答1:
It's not clear for me why you need to have implemented such strange behavior. Probably an example could clear all. Nevertheless the requirements is not difficult to implement.
You can use oneditfunc
parameter of the editRow to do some actions at the beginning of the editing. Because not only text input fields are possible, you have to do different actions for different controls. For example, in case of text input and the checkboxes the code could be the following
grid.jqGrid('editRow', rowid, true, function () {
var $tr = $(e.target).closest('tr')[0],
$selectedCell = $("input, select", e.target);
$("input:text", $tr).val('');
$("input:checkbox", $tr).prop("checked", false);
}
(where var grid = $("#list");
). In case of other controls you have to implement additional actions.
See the demo here.
回答2:
beforeShowForm: function(form) {
$("#Row id 1", form).val('');
$("#Row id 2", form).val('');
}
来源:https://stackoverflow.com/questions/6887164/clear-all-the-existing-content-in-a-row-in-jqgrid-inline-edit-and-open-fresh-inp