jQGrid - 表单添加和编辑编辑选项:禁用设置在添加&之间切换编辑

时间:2014-03-11 22:29:46

标签: jquery forms jqgrid

我正在使用表单来添加和编辑记录。添加时,我希望可以编辑两列。编辑时,我不希望用户编辑这些列中的值,但我仍然希望在表单上显示数据。 我正在使用beforeShowForm将禁用的编辑选项设置为禁用:false表示添加和禁用:true表示编辑。 我第一次打开添加表单时,一切正常。当我再次打开它时,两列被禁用。如果我打开已禁用列的编辑表单,然后返回添加,则列可再次编辑。 请提供有关如何使表单始终可编辑的信息。我到目前为止所做的一切都不起作用。 谢谢。

.jqGrid('navGrid','#pager',{add:true, edit:true, del:true},
            {//add option
                beforeShowForm: function(formid) {
                    $(this).jqGrid('setColProp', 'messageId', {editoptions:{disabled:false}});
                    $(this).jqGrid('setColProp', 'messageSubId', {editoptions:{disabled:false}});
                }
            },
            {//edit option
                beforeShowForm: function(formid) {
                    $(this).jqGrid('setColProp', 'messageId', {editoptions:{disabled:true}});
                    $(this).jqGrid('setColProp', 'messageSubId', {editoptions:{disabled:true}});
                }
            },
            {width: 450}, {width: 450});

这是网格的编辑部分。

jQuery.extend(jQuery.jgrid.edit, {
ajaxEditOptions: { contentType: "application/json"},
savekey: [true, 13],
closeAfterAdd: true,
recreateForm: true,
closeOnEscape: true,
modal: true,
serializeEditData: function (postData) {
    postData.messageClassId = currentVal;
    return JSON.stringify(postData);
},
afterSubmit: function (response, postdata) {
     $("#msgAdmin").setGridParam({datatype:'json', page:1}).trigger('reloadGrid');
     return [true,'']; // No error
 }, 
beforeSubmit: function(postdata, formid) {
    // Form field validations

afterComplete : function(response, postdata, formid) {                      
    buildGrid();
 },
errorTextFormat: function (response) {
    if (response.status != '200') {
        return 'Error: ' + response.responseText;
    }
    else {
        return 'Data Saved!';
    }
    return [true,'']; // no error
}

});

0 个答案:

没有答案
相关问题