jqgrid_utils 1.4.0 → 1.4.3

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.
@@ -23,6 +23,44 @@ module.exports = class Vanilla_website_utils
23
23
  }
24
24
 
25
25
 
26
+
27
+
28
+ /**
29
+ * Add an OK Button
30
+ @alias module:Jqgrid_utils
31
+ @param {array} - grid col_model
32
+ @param {array} - list of columns names what will be converted to ok buttons
33
+ @returns {array} - col_model
34
+ @example
35
+ var jqu = new Jqgrid_utils();
36
+ col_model = await jqu.add_ok_button(col_model, ['checked']);
37
+ */
38
+
39
+ async add_ok_button(col_model, fields)
40
+ {
41
+ let self = this;
42
+ for (let i = 0; i < col_model.length; i++)
43
+ {
44
+ if (fields.indexOf(col_model[i]['name']) > -1)
45
+ {
46
+ col_model[i]['formatter'] = function(cell_val)
47
+ {
48
+ if (cell_val != undefined)
49
+ {
50
+ return self.__cell_format(cell_val, 'format_ok');
51
+ }
52
+ else
53
+ {
54
+ return '';
55
+ }
56
+ };
57
+ }
58
+ }
59
+ return col_model;
60
+ }
61
+
62
+
63
+
26
64
  /**
27
65
  * Get the filled cell data
28
66
  @alias module:Jqgrid_utils
@@ -33,7 +71,6 @@ module.exports = class Vanilla_website_utils
33
71
  var jqu = new Jqgrid_utils();
34
72
  col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
35
73
  */
36
-
37
74
  async get_filled_cell_table_data(_grid, fields=[])
38
75
  {
39
76
  let d = jQuery(_grid).jqGrid('getGridParam','data');
@@ -137,11 +174,11 @@ console.log(_data);
137
174
 
138
175
  /**
139
176
  * Hide a col_model column before load the grid
140
- @alias module:Jqgrid_utils
141
- @param {object} - col_model of the grid
142
- @param {string} - name of the column to hide
143
- @returns {object} col_model
144
- @example
177
+ * @alias module:Jqgrid_utils
178
+ * @param {object} - col_model of the grid
179
+ * @param {string} - name of the column to hide
180
+ * @returns {object} col_model
181
+ * @example
145
182
  if(filter['_filter'] == 'ch_p_higher_ch_plus_10pc')
146
183
  {
147
184
  col_model = await jqu.hide_column(col_model,'wholesale');
@@ -748,11 +785,11 @@ __cell_format(cell_value, format)
748
785
  {
749
786
  if (cell_value == 0 || cell_value === 'fail')
750
787
  {
751
- cell_value = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
788
+ cell_value = '<i data-check="failed" class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
752
789
  }
753
790
  else
754
791
  {
755
- cell_value = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
792
+ cell_value = '<i data-check="ok" class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
756
793
  }
757
794
  }
758
795
  return cell_value;
package/jqgrid_utils.js CHANGED
@@ -22,6 +22,44 @@ module.exports = class Vanilla_website_utils
22
22
  }
23
23
 
24
24
 
25
+
26
+
27
+ /**
28
+ * Add an OK Button
29
+ @alias module:Jqgrid_utils
30
+ @param {array} - grid col_model
31
+ @param {array} - list of columns names what will be converted to ok buttons
32
+ @returns {array} - col_model
33
+ @example
34
+ var jqu = new Jqgrid_utils();
35
+ col_model = await jqu.add_ok_button(col_model, ['checked']);
36
+ */
37
+
38
+ async add_ok_button(col_model, fields)
39
+ {
40
+ let self = this;
41
+ for (let i = 0; i < col_model.length; i++)
42
+ {
43
+ if (fields.indexOf(col_model[i]['name']) > -1)
44
+ {
45
+ col_model[i]['formatter'] = function(cell_val)
46
+ {
47
+ if (cell_val != undefined)
48
+ {
49
+ return self.__cell_format(cell_val, 'format_ok');
50
+ }
51
+ else
52
+ {
53
+ return '';
54
+ }
55
+ };
56
+ }
57
+ }
58
+ return col_model;
59
+ }
60
+
61
+
62
+
25
63
  /**
26
64
  * Get the filled cell data
27
65
  @alias module:Jqgrid_utils
@@ -32,7 +70,6 @@ module.exports = class Vanilla_website_utils
32
70
  var jqu = new Jqgrid_utils();
33
71
  col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
34
72
  */
35
-
36
73
  async get_filled_cell_table_data(_grid, fields=[])
37
74
  {
38
75
  let d = jQuery(_grid).jqGrid('getGridParam','data');
@@ -136,11 +173,11 @@ console.log(_data);
136
173
 
137
174
  /**
138
175
  * Hide a col_model column before load the grid
139
- @alias module:Jqgrid_utils
140
- @param {object} - col_model of the grid
141
- @param {string} - name of the column to hide
142
- @returns {object} col_model
143
- @example
176
+ * @alias module:Jqgrid_utils
177
+ * @param {object} - col_model of the grid
178
+ * @param {string} - name of the column to hide
179
+ * @returns {object} col_model
180
+ * @example
144
181
  if(filter['_filter'] == 'ch_p_higher_ch_plus_10pc')
145
182
  {
146
183
  col_model = await jqu.hide_column(col_model,'wholesale');
@@ -747,11 +784,11 @@ __cell_format(cell_value, format)
747
784
  {
748
785
  if (cell_value == 0 || cell_value === 'fail')
749
786
  {
750
- cell_value = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
787
+ cell_value = '<i data-check="failed" class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
751
788
  }
752
789
  else
753
790
  {
754
- cell_value = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
791
+ cell_value = '<i data-check="ok" class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
755
792
  }
756
793
  }
757
794
  return cell_value;
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.4.0"
32
+ "version": "1.4.3"
33
33
  }