我正在使用jqgrid 4.5.2版本與Jquery-3.2.1。beforeSubmit事件自定義按鈕上的自定義形式的jqgrid不起作用
在jqgrid中,代替編輯按鈕(添加,編輯和刪除)自定義(添加,編輯和刪除)按鈕被實現。現在點擊自定義添加/編輯按鈕打開一個自定義窗體。以下是自定義按鈕的onclick事件。
這意味着我們用我們自己的自定義窗體替換了jqgrid的默認編輯/添加窗體。之前我們用beforeSubmit事件寫了一些驗證,這些驗證使用jqgrid的默認(添加/編輯)形式正常工作。現在我想對替換的自定義表單應用相同的驗證。
function(myGrid){
myGrid.getGridParam('dataGrid').openEditFormIndicator();
}(myGrid)
該自定義窗體具有自定義提交和取消按鈕。現在我想添加beforeSubmit事件到這個提交按鈕。由於表單是自定義的,jqgrids默認的beforeSubmit事件不起作用。
添加/編輯表單是由我們自己的構建在Java上的框架構建的。這些表格完全獨立於jqgrid。我只是從jqgrid行獲得id(雙擊或單擊編輯按鈕)並將其傳遞給模板,該模板從db中獲取數據並形成行編輯表單。如果傳遞的id爲空或者沒有在數據庫中找到,則使用相同的模板形成一個空的(添加)表單。
DataGrid.prototype.openEditFormIndicator = function() {
var id = this.grid.getGridParam('selrow')
if(!id) {
var gridId = this.grid.attr('id');
var idSelector = "#alertmod_" + gridId;
$.jgrid.viewModal(idSelector, {
gbox: "#gbox_" + $.jgrid.jqID(gridId),
jqm: true
});
$(idSelector).find(".ui-jqdialog-titlebar-close").focus();
}
else {
//openInteractiveForm('form_plugin_examples',this.options.formIndicatorId,'id',id,'true');
var encodedPkId = encodeURIComponent(id);
this.openFormIndicator('Id:' + encodedPkId + ',pkId:' + encodedPkId + ',Search:id%3A' + encodedPkId + ',IndicatorId:' + this.options.formIndicatorId + ',Debug:true' + ',FilterField:id,FilterValue:' + encodedPkId);
// TODO width, length, position
}
};
DataGrid.prototype.openFormIndicator = function(optionsStr) {
DialogBoxEdit.newWindow(this.options.formIndicatorId, optionsStr);
};
通過以上兩個函數,在DialogBoxEditHandler.js中添加/編輯窗體。 js內部調用一個模板來創建表單。
創建的表單包含以下兩個按鈕,爲此我需要添加beforeSubmit事件。
<Button id="lnk-close" onclick="closeDialogBoxControl($(this).closest('form'));" class="btn-default">Close</Button>
<Button id="lnk-submit" onclick="save_form_data($(this).closest('form'),true,'72');MD.ui.reloadGrid();" class="btn-primary ui-dialog-close">Save</Button>
如果您希望在此問題上獲得幫助,則需要提供代碼。 –
@AnteJablanAdamović:這是一個普遍的問題。我沒有遇到任何與我寫的代碼有關的問題。這是一個新的實現,並沒有找到任何幫助谷歌。相信我的問題解釋了我需要的東西。 – santoshM
它沒有,沒有看到你的代碼,我們不知道你如何約束beforeSubmit事件,因此我們無法幫助你。 –