jqgrid_utils 1.8.0 → 1.9.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.
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> ⏏
@@ -23,33 +23,56 @@ module.exports = class Vanilla_website_utils
23
23
  }
24
24
 
25
25
 
26
+ /**
27
+ * add textarea
28
+ @alias module:Jqgrid_utils
29
+ @param {object} - edittype like
30
+ @example
31
+ let col_model = JSON.parse(await aget_api(url + "/model"));
32
+ col_model = await jqu.add_edit(col_model, 'mon',{ edittype:'textarea', editoptions:{rows:6,cols:100} });
33
+ see for other inputfields:
34
+ http://www.trirand.com/blog/phpjqgrid/doc/_2v80w6oam.htm
35
+ */
36
+ async add_edit(col_model, edit_field, edittype, editoptions)
37
+ {
38
+ for (let i = 0; i < col_model.length; i++)
39
+ {
40
+ if (col_model[i]['name'] === edit_field)
41
+ {
42
+ Object.assign(col_model[i], edittype );
43
+ Object.assign(col_model[i], editoptions );
44
+ }
45
+ }
46
+ return col_model;
47
+ }
26
48
 
49
+
27
50
  /**
28
51
  * add textarea
29
52
  @alias module:Jqgrid_utils
30
53
  @param {string} - edit_filed
31
54
  @param {string} - style of the textaread
32
55
  @example
33
- var jqu = new Jqgrid_utils();
34
- let _data = jqu._date112_to_DMY('20220104','/');
35
- console.log(_data);
56
+ let col_model = JSON.parse(await aget_api(url + "/model"));
57
+ col_model = await jqu.add_textarea(col_model, 'worker','style="width:100%;height:100px"');
36
58
  */
37
- async add_textarea(col_model, edit_field, style = 'style="width:100%;height:450px"')
59
+ async add_textarea(col_model, edit_field, style = 'style="width:100%;height:100px"')
38
60
  {
39
- let f = window.sqlFormatter;
40
61
  for (let i = 0; i < col_model.length; i++)
41
62
  {
42
63
  if (col_model[i]['name'] === edit_field)
43
64
  {
44
65
  col_model[i]['formatter'] = function(cell_val)
45
66
  {
46
- let sql = '<textarea '+ style +'>' + cell_val + '</textarea>' ;
47
- return sql;
67
+ const txt = '<textarea '+ style +'>' + cell_val + '</textarea>' ;
68
+ return txt;
48
69
  };
49
70
  }
50
71
  }
51
72
  return col_model;
52
73
  }
74
+
75
+
53
76
 
54
77
  /**
55
78
  * Get basic colModel data from raw data
package/jqgrid_utils.js CHANGED
@@ -22,33 +22,56 @@ module.exports = class Vanilla_website_utils
22
22
  }
23
23
 
24
24
 
25
+ /**
26
+ * add textarea
27
+ @alias module:Jqgrid_utils
28
+ @param {object} - edittype like
29
+ @example
30
+ let col_model = JSON.parse(await aget_api(url + "/model"));
31
+ col_model = await jqu.add_edit(col_model, 'mon',{ edittype:'textarea', editoptions:{rows:6,cols:100} });
32
+ see for other inputfields:
33
+ http://www.trirand.com/blog/phpjqgrid/doc/_2v80w6oam.htm
34
+ */
35
+ async add_edit(col_model, edit_field, edittype, editoptions)
36
+ {
37
+ for (let i = 0; i < col_model.length; i++)
38
+ {
39
+ if (col_model[i]['name'] === edit_field)
40
+ {
41
+ Object.assign(col_model[i], edittype );
42
+ Object.assign(col_model[i], editoptions );
43
+ }
44
+ }
45
+ return col_model;
46
+ }
25
47
 
48
+
26
49
  /**
27
50
  * add textarea
28
51
  @alias module:Jqgrid_utils
29
52
  @param {string} - edit_filed
30
53
  @param {string} - style of the textaread
31
54
  @example
32
- var jqu = new Jqgrid_utils();
33
- let _data = jqu._date112_to_DMY('20220104','/');
34
- console.log(_data);
55
+ let col_model = JSON.parse(await aget_api(url + "/model"));
56
+ col_model = await jqu.add_textarea(col_model, 'worker','style="width:100%;height:100px"');
35
57
  */
36
- async add_textarea(col_model, edit_field, style = 'style="width:100%;height:450px"')
58
+ async add_textarea(col_model, edit_field, style = 'style="width:100%;height:100px"')
37
59
  {
38
- let f = window.sqlFormatter;
39
60
  for (let i = 0; i < col_model.length; i++)
40
61
  {
41
62
  if (col_model[i]['name'] === edit_field)
42
63
  {
43
64
  col_model[i]['formatter'] = function(cell_val)
44
65
  {
45
- let sql = '<textarea '+ style +'>' + cell_val + '</textarea>' ;
46
- return sql;
66
+ const txt = '<textarea '+ style +'>' + cell_val + '</textarea>' ;
67
+ return txt;
47
68
  };
48
69
  }
49
70
  }
50
71
  return col_model;
51
72
  }
73
+
74
+
52
75
 
53
76
  /**
54
77
  * Get basic colModel data from raw data
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.8.0"
32
+ "version": "1.9.0"
33
33
  }