Clear all the existing content in a row in jqgrid inline edit and open fresh input data fields.

房东的猫 提交于 2019-12-25 01:58:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!