jqgrid_utils 1.7.0 → 1.8.1

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.
package/README.md CHANGED
@@ -29,8 +29,10 @@ A module for Jqgrid_utils
29
29
  * [Jqgrid_utils](#module_Jqgrid_utils)
30
30
  * [module.exports#add_textarea(col_model, edit_field)](#exp_module_Jqgrid_utils--module.exports+add_textarea) ⏏
31
31
  * [module.exports#get_col_model_from_data(obj, data, exclude, col_model)](#exp_module_Jqgrid_utils--module.exports+get_col_model_from_data) ⇒ <code>array</code> ⏏
32
+ * [module.exports#binary_replace(cell_value, a, b)](#exp_module_Jqgrid_utils--module.exports+binary_replace) ⏏
32
33
  * [module.exports#_date112_to_DMY(cell_value, seperator)](#exp_module_Jqgrid_utils--module.exports+_date112_to_DMY) ⏏
33
34
  * [module.exports#date112_to_DMY(col_model, edit_field, seperator)](#exp_module_Jqgrid_utils--module.exports+date112_to_DMY) ⏏
35
+ * [module.exports#add_formatter(col_model, edit_field, formatter)](#exp_module_Jqgrid_utils--module.exports+add_formatter) ⏏
34
36
  * [module.exports#add_html_formatter(col_model, edit_field, html)](#exp_module_Jqgrid_utils--module.exports+add_html_formatter) ⇒ <code>array</code> ⏏
35
37
  * [module.exports#add_ok_button(col_model, fields)](#exp_module_Jqgrid_utils--module.exports+add_ok_button) ⇒ <code>array</code> ⏏
36
38
  * [module.exports#get_filled_cell_table_data(_grid, fields)](#exp_module_Jqgrid_utils--module.exports+get_filled_cell_table_data) ⇒ <code>array</code> ⏏
@@ -74,9 +76,8 @@ add textarea
74
76
 
75
77
  **Example**
76
78
  ```js
77
- var jqu = new Jqgrid_utils();
78
- let _data = jqu._date112_to_DMY('20220104','/');
79
- console.log(_data);
79
+ let col_model = JSON.parse(await aget_api(url + "/model"));
80
+ col_model = await jqu.add_textarea(col_model, 'worker','style="width:100%;height:100px"');
80
81
  ```
81
82
  <a name="exp_module_Jqgrid_utils--module.exports+get_col_model_from_data"></a>
82
83
 
@@ -103,6 +104,26 @@ var jqu = new Jqgrid_utils();
103
104
  jQuery(this).jqGrid('setGridParam',{colModel:new_col_model});
104
105
  },
105
106
  ```
107
+ <a name="exp_module_Jqgrid_utils--module.exports+binary_replace"></a>
108
+
109
+ ### module.exports#binary\_replace(cell_value, a, b) ⏏
110
+ Replace a Binaery 0 or 1 to other given value
111
+
112
+ **Kind**: Exported function
113
+
114
+ | Param | Type | Default | Description |
115
+ | --- | --- | --- | --- |
116
+ | cell_value | <code>string</code> | | cell value |
117
+ | a | <code>string</code> | <code>&quot;zero&quot;</code> | string replacement for 0 |
118
+ | b | <code>string</code> | <code>&quot;one&quot;</code> | string replacement for 1 |
119
+
120
+ **Example**
121
+ ```js
122
+ var jqu = new Jqgrid_utils();
123
+ let _data = jqu.binery_replace(0,'zero','one');
124
+ or for column formatter
125
+ download_formatter:"var jqu = new Jqgrid_utils();jqu.binary_replace({0},'zero','one')"});
126
+ ```
106
127
  <a name="exp_module_Jqgrid_utils--module.exports+_date112_to_DMY"></a>
107
128
 
108
129
  ### module.exports#\_date112\_to\_DMY(cell_value, seperator) ⏏
@@ -140,6 +161,24 @@ var jqu = new Jqgrid_utils();
140
161
  let _data = await jqu.date112_to_DMY(this,'field','/');
141
162
  console.log(_data);
142
163
  ```
164
+ <a name="exp_module_Jqgrid_utils--module.exports+add_formatter"></a>
165
+
166
+ ### module.exports#add\_formatter(col_model, edit_field, formatter) ⏏
167
+ Add Formatter
168
+
169
+ **Kind**: Exported function
170
+
171
+ | Param | Type | Description |
172
+ | --- | --- | --- |
173
+ | col_model | <code>array</code> | grid col_model |
174
+ | edit_field | <code>string</code> | string columns names what will be formatted |
175
+ | formatter | <code>object</code> | formatter object like { formatter: "select", formatoptions: {value: "1:ok;0:fail", defaultValue: "1" }} |
176
+
177
+ **Example**
178
+ ```js
179
+ var jqu = new Jqgrid_utils();
180
+ col_model = await jqu.add_formatter(col_model,'select',{ formatter: "select", formatoptions: {value: "1:ok;0:fail", defaultValue: "1" }})
181
+ ```
143
182
  <a name="exp_module_Jqgrid_utils--module.exports+add_html_formatter"></a>
144
183
 
145
184
  ### module.exports#add\_html\_formatter(col_model, edit_field, html) ⇒ <code>array</code> ⏏
@@ -30,11 +30,10 @@ module.exports = class Vanilla_website_utils
30
30
  @param {string} - edit_filed
31
31
  @param {string} - style of the textaread
32
32
  @example
33
- var jqu = new Jqgrid_utils();
34
- let _data = jqu._date112_to_DMY('20220104','/');
35
- console.log(_data);
33
+ let col_model = JSON.parse(await aget_api(url + "/model"));
34
+ col_model = await jqu.add_textarea(col_model, 'worker','style="width:100%;height:100px"');
36
35
  */
37
- async add_textarea(col_model, edit_field, style = 'style="width:100%;height:450px"')
36
+ async add_textarea(col_model, edit_field, style = 'style="width:100%;height:100px"')
38
37
  {
39
38
  let f = window.sqlFormatter;
40
39
  for (let i = 0; i < col_model.length; i++)
@@ -195,7 +194,36 @@ console.log(_data);
195
194
  return col_model;
196
195
  }
197
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
+ */
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
+ }
198
225
 
226
+
199
227
  /**
200
228
  * Add HTML Formatter
201
229
  @alias module:Jqgrid_utils
package/jqgrid_utils.js CHANGED
@@ -29,11 +29,10 @@ module.exports = class Vanilla_website_utils
29
29
  @param {string} - edit_filed
30
30
  @param {string} - style of the textaread
31
31
  @example
32
- var jqu = new Jqgrid_utils();
33
- let _data = jqu._date112_to_DMY('20220104','/');
34
- console.log(_data);
32
+ let col_model = JSON.parse(await aget_api(url + "/model"));
33
+ col_model = await jqu.add_textarea(col_model, 'worker','style="width:100%;height:100px"');
35
34
  */
36
- async add_textarea(col_model, edit_field, style = 'style="width:100%;height:450px"')
35
+ async add_textarea(col_model, edit_field, style = 'style="width:100%;height:100px"')
37
36
  {
38
37
  let f = window.sqlFormatter;
39
38
  for (let i = 0; i < col_model.length; i++)
@@ -194,7 +193,36 @@ console.log(_data);
194
193
  return col_model;
195
194
  }
196
195
 
196
+ /**
197
+ * Add Formatter
198
+ @alias module:Jqgrid_utils
199
+ @param {array} - grid col_model
200
+ @param {string} - string columns names what will be formatted
201
+ @param {object} - formatter object like { formatter: "select", formatoptions: {value: "1:ok;0:fail", defaultValue: "1" }}
202
+ @example
203
+ var jqu = new Jqgrid_utils();
204
+ col_model = await jqu.add_formatter(col_model,'select',{ formatter: "select", formatoptions: {value: "1:ok;0:fail", defaultValue: "1" }})
205
+ */
206
+
207
+ async add_formatter(col_model,edit_field, formatter)
208
+ {
209
+ for(let i=0;i< col_model.length;i++)
210
+ {
211
+ if(col_model[i]['name'] === edit_field)
212
+ {
213
+ if(formatter.hasOwnProperty('formatter') && formatter.hasOwnProperty('formatoptions'))
214
+ {
215
+ col_model[i]['formatter'] = formatter['formatter'];
216
+ col_model[i]['formatoptions'] = formatter['formatoptions'];
217
+ col_model[i]['edittype'] = formatter['formatter'];
218
+ col_model[i]['editoptions'] = formatter['formatoptions'];
219
+ }
220
+ }
221
+ }
222
+ return col_model;
223
+ }
197
224
 
225
+
198
226
  /**
199
227
  * Add HTML Formatter
200
228
  @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.1"
33
33
  }