jqgrid_utils 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -195,7 +195,36 @@ console.log(_data);
195
195
  return col_model;
196
196
  }
197
197
 
198
+ /**
199
+ * Add Formatter
200
+ @alias module:Jqgrid_utils
201
+ @param {array} - grid col_model
202
+ @param {string} - string columns names what will be formatted
203
+ @param {object} - formatter object like { formatter: "select", formatoptions: {value: "1:ok;0:fail", defaultValue: "1" }}
204
+ @example
205
+ var jqu = new Jqgrid_utils();
206
+ col_model = await jqu.add_formatter(col_model,'select',{ formatter: "select", formatoptions: {value: "1:ok;0:fail", defaultValue: "1" }})
207
+ */
198
208
 
209
+ async add_formatter(col_model,edit_field, formatter)
210
+ {
211
+ for(let i=0;i< col_model.length;i++)
212
+ {
213
+ if(col_model[i]['name'] === edit_field)
214
+ {
215
+ if(formatter.hasOwnProperty('formatter') && formatter.hasOwnProperty('formatoptions'))
216
+ {
217
+ col_model[i]['formatter'] = formatter['formatter'];
218
+ col_model[i]['formatoptions'] = formatter['formatoptions'];
219
+ col_model[i]['edittype'] = formatter['formatter'];
220
+ col_model[i]['editoptions'] = formatter['formatoptions'];
221
+ }
222
+ }
223
+ }
224
+ return col_model;
225
+ }
226
+
227
+
199
228
  /**
200
229
  * Add HTML Formatter
201
230
  @alias module:Jqgrid_utils
package/jqgrid_utils.js CHANGED
@@ -194,7 +194,36 @@ console.log(_data);
194
194
  return col_model;
195
195
  }
196
196
 
197
+ /**
198
+ * Add Formatter
199
+ @alias module:Jqgrid_utils
200
+ @param {array} - grid col_model
201
+ @param {string} - string columns names what will be formatted
202
+ @param {object} - formatter object like { formatter: "select", formatoptions: {value: "1:ok;0:fail", defaultValue: "1" }}
203
+ @example
204
+ var jqu = new Jqgrid_utils();
205
+ col_model = await jqu.add_formatter(col_model,'select',{ formatter: "select", formatoptions: {value: "1:ok;0:fail", defaultValue: "1" }})
206
+ */
197
207
 
208
+ async add_formatter(col_model,edit_field, formatter)
209
+ {
210
+ for(let i=0;i< col_model.length;i++)
211
+ {
212
+ if(col_model[i]['name'] === edit_field)
213
+ {
214
+ if(formatter.hasOwnProperty('formatter') && formatter.hasOwnProperty('formatoptions'))
215
+ {
216
+ col_model[i]['formatter'] = formatter['formatter'];
217
+ col_model[i]['formatoptions'] = formatter['formatoptions'];
218
+ col_model[i]['edittype'] = formatter['formatter'];
219
+ col_model[i]['editoptions'] = formatter['formatoptions'];
220
+ }
221
+ }
222
+ }
223
+ return col_model;
224
+ }
225
+
226
+
198
227
  /**
199
228
  * Add HTML Formatter
200
229
  @alias module:Jqgrid_utils
package/package.json CHANGED
@@ -29,5 +29,5 @@
29
29
  {
30
30
  "test": "echo \"Error: no test specified\" && exit 1"
31
31
  },
32
- "version": "1.7.0"
32
+ "version": "1.8.0"
33
33
  }