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