In order to be able to access another editing field inside any event handler defined in dataEvents , you need to use the corresponding name translation for identifiers used in another editing mode.
Editing a form creates editing elements with an id attribute in the same way as the name property in colModel . Built-in editing allows you to edit multiple lines at once. Therefore, another rule is used to construct id values: the rowid value will be added _ , and then added with the value of the name property in colModel . During cell editing, jqGrid allows you to edit only one cell. Therefore, accessing another editing field inside any event handler defined in dataEvents does not make sense.
The answer gives an example of detecting edit mode inside the dataEvents event dataEvents .
We have a column { name: "appc", formatter: "checkbox", editable: true, edittype: "checkbox", ...} , and you need to define a change event handler for the column. You have another text column { name: "appdate", editable: true, ...} , and you want to change the value of the edit field of the appdate column when checking or appc box in the appc column. In this case, you can do the following:
{ name: "appdate", editable: true, ...}, { name: "appc", formatter: "checkbox", editable: true, edittype: "checkbox", editoptions: { dataEvents: [{ type: "change", fn: function (e) { var $this = $(e.target), columnName = "appdate", rowid, cellId; if ($this.hasClass("FormElement")) {
UPDATED . From your question, you can change the following code:
var date = new Date(Date.now()), todayDate = function (date) { return (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear(); }, checkBoxChange = function (e) { var $this = $(e.target), columnName = e.data.dateColumn, rowid, cellId; if ($this.hasClass("FormElement")) {
You can see that we use data: { dateColumn: "devdate" } or data: { dateColumn: "appdate" } as an additional property of dataEvents elements. The checkBoxChange event checkBoxChange used in fn: checkBoxChange can access data by using e.data.dateColumn . In the method, you can easily use the same event handler for multiple columns.