beforeSubmit event isn't added to the jqgrid-4.5.2

╄→尐↘猪︶ㄣ 提交于 2019-12-25 12:01:08

问题


I am using jqgrid 4.5.2 version with Jquery-3.2.1. Not able to bind the beforeSubmit function to the jqgrid.

Below is the sample code to bind the event.

var config = {};
config.beforeSubmit = function(grid, postData, formid, frmoper){
   ....
}
if (config.beforeSubmit) {
    this.grid.off('jqGridAddEditBeforeSubmit').on("jqGridAddEditBeforeSubmit", config.beforeSubmit);
}

Would be thankful if someone could help me on this.

Below is a brief explanation on how the beforeSubmit event is added in my application

In my case we are overriding the jqgrid library with a DataGrid.js file. In this, I have a function named DataGrid.buildGrid = function(configXml, params, cb), which is called at run time and builds the grid dynamically. This function internally calls generateGrid().

DataGrid.buildGrid = function(configXml, params, cb) {
  ....
  ....
  var myGrid = new DataGrid(jqConfig, params);
  myGrid.generateGrid();
}

the below is the sample generateGrid() code:

DataGrid.prototype.generateGrid = function() {
  ...
  var jqConfig = DataGrid.getJqConfig(form, params, cb);
  ...
  this.bindConfigEvents();
}

in getJqConfig() we are adding the beforeSubmit event to jqConfig object

DataGrid.getJqConfig = function(form, options, cb) {
  var jqConfig = {};
  ....
  ....
  config.beforeSubmit = function(grid, postData, formid, frmoper){
  ....
}

in bindConfigEvents() function we are binding the beforeSubmit

DataGrid.prototype.bindConfigEvents = function() {
  ...
  ...
  if (this.jqConfig.beforeSubmit) {
    this.grid.off('jqGridAddEditBeforeSubmit').on("jqGridAddEditBeforeSubmit", this.jqConfig.beforeSubmit);
  }
}

来源:https://stackoverflow.com/questions/46211943/beforesubmit-event-isnt-added-to-the-jqgrid-4-5-2

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