Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

jquery - beforeSubmit event isn't added to the jqgrid-4.5.2

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);
  }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...