jqgrid_utils 1.3.1 → 1.3.4

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
@@ -36,6 +36,8 @@ A module for Jqgrid_utils
36
36
 
37
37
 
38
38
  * [Jqgrid_utils](#module_Jqgrid_utils)
39
+ * [module.exports#get_filled_cell_table_data(_grid, fields)](#exp_module_Jqgrid_utils--module.exports+get_filled_cell_table_data) ⇒ <code>array</code> ⏏
40
+ * [module.exports#get_filled_cell_data(_grid, fields)](#exp_module_Jqgrid_utils--module.exports+get_filled_cell_data) ⇒ <code>object</code> ⏏
39
41
  * [module.exports#set_link(col_model, edit_field, url)](#exp_module_Jqgrid_utils--module.exports+set_link) ⇒ <code>string</code> ⏏
40
42
  * [module.exports#s_grid_set_caption(_grid, data)](#exp_module_Jqgrid_utils--module.exports+s_grid_set_caption) ⏏
41
43
  * [module.exports#grid_set_caption(_grid, data)](#exp_module_Jqgrid_utils--module.exports+grid_set_caption) ⏏
@@ -60,6 +62,42 @@ A module for Jqgrid_utils
60
62
  * [module.exports#set_filter(grid, data, fx, append_to)](#exp_module_Jqgrid_utils--module.exports+set_filter) ⏏
61
63
  * [module.exports#_filter()](#exp_module_Jqgrid_utils--module.exports+_filter) ⏏
62
64
 
65
+ <a name="exp_module_Jqgrid_utils--module.exports+get_filled_cell_table_data"></a>
66
+
67
+ ### module.exports#get\_filled\_cell\_table\_data(_grid, fields) ⇒ <code>array</code> ⏏
68
+ Get the filled cell data
69
+
70
+ **Kind**: Exported function
71
+ **Returns**: <code>array</code> - - table array
72
+
73
+ | Param | Type | Description |
74
+ | --- | --- | --- |
75
+ | _grid | <code>object</code> | the grid object or its name |
76
+ | fields | <code>array</code> | list of columns names what will be collected |
77
+
78
+ **Example**
79
+ ```js
80
+ var jqu = new Jqgrid_utils();
81
+ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
82
+ ```
83
+ <a name="exp_module_Jqgrid_utils--module.exports+get_filled_cell_data"></a>
84
+
85
+ ### module.exports#get\_filled\_cell\_data(_grid, fields) ⇒ <code>object</code> ⏏
86
+ Get the filled cell data
87
+
88
+ **Kind**: Exported function
89
+ **Returns**: <code>object</code> - - json object of the colleted fields
90
+
91
+ | Param | Type | Description |
92
+ | --- | --- | --- |
93
+ | _grid | <code>object</code> | the grid object or its name |
94
+ | fields | <code>array</code> | list of columns names what will be collected |
95
+
96
+ **Example**
97
+ ```js
98
+ var jqu = new Jqgrid_utils();
99
+ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
100
+ ```
63
101
  <a name="exp_module_Jqgrid_utils--module.exports+set_link"></a>
64
102
 
65
103
  ### module.exports#set\_link(col_model, edit_field, url) ⇒ <code>string</code> ⏏
@@ -77,7 +115,8 @@ Add an URL from the data to a specific cell/column
77
115
  **Example**
78
116
  ```js
79
117
  var jqu = new Jqgrid_utils();
80
- col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
118
+ let _data = await jqu.get_filled_cell_data(this,["P-","bulk","wholesale"]);
119
+ console.log(_data);
81
120
  ```
82
121
  <a name="exp_module_Jqgrid_utils--module.exports+s_grid_set_caption"></a>
83
122
 
@@ -99,6 +138,8 @@ loadComplete: function(){
99
138
  <a name="exp_module_Jqgrid_utils--module.exports+grid_set_caption"></a>
100
139
 
101
140
  ### module.exports#grid\_set\_caption(_grid, data) ⏏
141
+ Adding the row count number to the caption
142
+
102
143
  **Kind**: Exported function
103
144
 
104
145
  | Param | Type | Description |
@@ -22,10 +22,89 @@ module.exports = class Vanilla_website_utils
22
22
 
23
23
  }
24
24
 
25
- async s_set_link(col_model, edit_field, url ,attr='')
25
+
26
+ /**
27
+ * Get the filled cell data
28
+ @alias module:Jqgrid_utils
29
+ @param {object} - the grid object or its name
30
+ @param {array} - list of columns names what will be collected
31
+ @returns {array} - table array
32
+ @example
33
+ var jqu = new Jqgrid_utils();
34
+ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
35
+ */
36
+
37
+ async get_filled_cell_table_data(_grid, fields=[])
26
38
  {
27
- this.set_link(col_model, edit_field, url ,attr);
28
- }
39
+ let d = jQuery(_grid).jqGrid('getGridParam','data');
40
+ let keys = fields;
41
+ let _data = [];
42
+ for(let i in d)
43
+ {
44
+ if(d[i].hasOwnProperty('id'))
45
+ {
46
+ let row = [d[i]['id']];
47
+ for(let x in keys)
48
+ {
49
+ if(d[i].hasOwnProperty(keys[x]))
50
+ {
51
+ row.push(d[i][keys[x]]);
52
+ }
53
+ else
54
+ {
55
+ row.push("");
56
+ }
57
+ }
58
+ var f = row.filter(function(value, index, arr){ return value !== "";});
59
+ if(Object.keys(f).length > 1)
60
+ {
61
+ _data.push(row);
62
+ }
63
+ }
64
+ }
65
+ return _data;
66
+ }
67
+
68
+
69
+ /**
70
+ * Get the filled cell data
71
+ @alias module:Jqgrid_utils
72
+ @param {object} - the grid object or its name
73
+ @param {array} - list of columns names what will be collected
74
+ @returns {object} - json object of the colleted fields
75
+ @example
76
+ var jqu = new Jqgrid_utils();
77
+ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
78
+ */
79
+
80
+ async get_filled_cell_data(_grid, fields=[])
81
+ {
82
+ let d = jQuery(_grid).jqGrid('getGridParam','data');
83
+ let keys = fields;
84
+ let _data = [];
85
+ for(let i in d)
86
+ {
87
+ if(d[i].hasOwnProperty('id'))
88
+ {
89
+ let row = {'id':d[i]['id']};
90
+ for(let x in keys)
91
+ {
92
+ if(d[i].hasOwnProperty(keys[x]))
93
+ {
94
+ if(d[i][keys[x]] != "")
95
+ {
96
+ row[keys[x]] = d[i][keys[x]];
97
+ }
98
+ }
99
+ }
100
+ if(Object.keys(row).length > 1)
101
+ {
102
+ _data.push(row);
103
+ }
104
+ }
105
+ }
106
+ return _data;
107
+ }
29
108
 
30
109
  /**
31
110
  * Add an URL from the data to a specific cell/column
@@ -36,7 +115,8 @@ module.exports = class Vanilla_website_utils
36
115
  @returns {string} https://foo.bar.com/av0_code/bar
37
116
  @example
38
117
  var jqu = new Jqgrid_utils();
39
- col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
118
+ let _data = await jqu.get_filled_cell_data(this,["P-","bulk","wholesale"]);
119
+ console.log(_data);
40
120
  */
41
121
  async set_link(col_model, edit_field, url ,attr='')
42
122
  {
@@ -70,6 +150,7 @@ loadComplete: function(){
70
150
  }
71
151
 
72
152
  /**
153
+ Adding the row count number to the caption
73
154
  @alias module:Jqgrid_utils
74
155
  @param {object} - gridobject;
75
156
  @param {object} - grid data (optional);
@@ -94,7 +175,7 @@ loadComplete: function(){
94
175
  let caption = grid.jqGrid("getGridParam", "caption");
95
176
  const reg = /\d.*x/;
96
177
  const new_caption = caption.replace(reg, "");
97
- grid.jqGrid('setCaption', new_caption + count + 'x');
178
+ grid.jqGrid('setCaption', new_caption + " " + count + 'x');
98
179
  }
99
180
 
100
181
  /**
package/jqgrid_utils.js CHANGED
@@ -21,10 +21,89 @@ module.exports = class Vanilla_website_utils
21
21
 
22
22
  }
23
23
 
24
- async s_set_link(col_model, edit_field, url ,attr='')
24
+
25
+ /**
26
+ * Get the filled cell data
27
+ @alias module:Jqgrid_utils
28
+ @param {object} - the grid object or its name
29
+ @param {array} - list of columns names what will be collected
30
+ @returns {array} - table array
31
+ @example
32
+ var jqu = new Jqgrid_utils();
33
+ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
34
+ */
35
+
36
+ async get_filled_cell_table_data(_grid, fields=[])
25
37
  {
26
- this.set_link(col_model, edit_field, url ,attr);
27
- }
38
+ let d = jQuery(_grid).jqGrid('getGridParam','data');
39
+ let keys = fields;
40
+ let _data = [];
41
+ for(let i in d)
42
+ {
43
+ if(d[i].hasOwnProperty('id'))
44
+ {
45
+ let row = [d[i]['id']];
46
+ for(let x in keys)
47
+ {
48
+ if(d[i].hasOwnProperty(keys[x]))
49
+ {
50
+ row.push(d[i][keys[x]]);
51
+ }
52
+ else
53
+ {
54
+ row.push("");
55
+ }
56
+ }
57
+ var f = row.filter(function(value, index, arr){ return value !== "";});
58
+ if(Object.keys(f).length > 1)
59
+ {
60
+ _data.push(row);
61
+ }
62
+ }
63
+ }
64
+ return _data;
65
+ }
66
+
67
+
68
+ /**
69
+ * Get the filled cell data
70
+ @alias module:Jqgrid_utils
71
+ @param {object} - the grid object or its name
72
+ @param {array} - list of columns names what will be collected
73
+ @returns {object} - json object of the colleted fields
74
+ @example
75
+ var jqu = new Jqgrid_utils();
76
+ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
77
+ */
78
+
79
+ async get_filled_cell_data(_grid, fields=[])
80
+ {
81
+ let d = jQuery(_grid).jqGrid('getGridParam','data');
82
+ let keys = fields;
83
+ let _data = [];
84
+ for(let i in d)
85
+ {
86
+ if(d[i].hasOwnProperty('id'))
87
+ {
88
+ let row = {'id':d[i]['id']};
89
+ for(let x in keys)
90
+ {
91
+ if(d[i].hasOwnProperty(keys[x]))
92
+ {
93
+ if(d[i][keys[x]] != "")
94
+ {
95
+ row[keys[x]] = d[i][keys[x]];
96
+ }
97
+ }
98
+ }
99
+ if(Object.keys(row).length > 1)
100
+ {
101
+ _data.push(row);
102
+ }
103
+ }
104
+ }
105
+ return _data;
106
+ }
28
107
 
29
108
  /**
30
109
  * Add an URL from the data to a specific cell/column
@@ -35,7 +114,8 @@ module.exports = class Vanilla_website_utils
35
114
  @returns {string} https://foo.bar.com/av0_code/bar
36
115
  @example
37
116
  var jqu = new Jqgrid_utils();
38
- col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
117
+ let _data = await jqu.get_filled_cell_data(this,["P-","bulk","wholesale"]);
118
+ console.log(_data);
39
119
  */
40
120
  async set_link(col_model, edit_field, url ,attr='')
41
121
  {
@@ -69,6 +149,7 @@ loadComplete: function(){
69
149
  }
70
150
 
71
151
  /**
152
+ Adding the row count number to the caption
72
153
  @alias module:Jqgrid_utils
73
154
  @param {object} - gridobject;
74
155
  @param {object} - grid data (optional);
@@ -93,7 +174,7 @@ loadComplete: function(){
93
174
  let caption = grid.jqGrid("getGridParam", "caption");
94
175
  const reg = /\d.*x/;
95
176
  const new_caption = caption.replace(reg, "");
96
- grid.jqGrid('setCaption', new_caption + count + 'x');
177
+ grid.jqGrid('setCaption', new_caption + " " + count + 'x');
97
178
  }
98
179
 
99
180
  /**
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.3.1"
32
+ "version": "1.3.4"
33
33
  }