jqgrid_utils 1.3.2 → 1.3.6
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 +68 -7
- package/dist/jqgrid_utils.js +119 -9
- package/jqgrid_utils.js +119 -9
- package/package.json +1 -1
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) ⏏
|
|
@@ -55,11 +57,47 @@ A module for Jqgrid_utils
|
|
|
55
57
|
* [module.exports#add_link_details_separator(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details_separator) ⏏
|
|
56
58
|
* [module.exports#add_link_separator(col_model, url, edit_field, fields)](#exp_module_Jqgrid_utils--module.exports+add_link_separator) ⏏
|
|
57
59
|
* [module.exports#__cell_format()](#exp_module_Jqgrid_utils--module.exports+__cell_format) ⏏
|
|
58
|
-
* [module.exports#subgrid(_id, id,
|
|
60
|
+
* [module.exports#subgrid(_id, id, url, col_model, caption)](#exp_module_Jqgrid_utils--module.exports+subgrid) ⏏
|
|
59
61
|
* [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Jqgrid_utils--module.exports+add_image) ⏏
|
|
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
|
-
|
|
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
|
|
|
@@ -404,22 +443,44 @@ Private Function
|
|
|
404
443
|
**Kind**: Exported function
|
|
405
444
|
<a name="exp_module_Jqgrid_utils--module.exports+subgrid"></a>
|
|
406
445
|
|
|
407
|
-
### module.exports#subgrid(_id, id,
|
|
446
|
+
### module.exports#subgrid(_id, id, url, col_model, caption) ⏏
|
|
408
447
|
**Kind**: Exported function
|
|
409
448
|
|
|
410
449
|
| Param | Type | Description |
|
|
411
450
|
| --- | --- | --- |
|
|
412
451
|
| _id | <code>string</code> | row_id |
|
|
413
452
|
| id | <code>string</code> | data id |
|
|
414
|
-
|
|
|
453
|
+
| url | <code>string</code> | url to request |
|
|
415
454
|
| col_model | <code>object</code> | col_model for the table |
|
|
416
455
|
| caption | <code>string</code> | Add to the caption of the subgrid |
|
|
417
456
|
|
|
418
457
|
**Example**
|
|
419
458
|
```js
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
let
|
|
459
|
+
subGrid: true,
|
|
460
|
+
,subGridRowExpanded: async function(_id, id) {
|
|
461
|
+
let data_url2 = api + '/process_locations?f=data&process=';
|
|
462
|
+
let col_model_url2 = api + '/process_locations?f=col_model';
|
|
463
|
+
let col_model2 = JSON.parse(await vwu.aget_api(col_model_url2));
|
|
464
|
+
await jqu.subgrid(_id, id, data_url2, col_model2,'Locations for Process');
|
|
465
|
+
|
|
466
|
+
let data_url = api + '/process_styles?f=data&process=';
|
|
467
|
+
let col_model_url = api + '/process_styles?f=col_model';
|
|
468
|
+
let col_model = JSON.parse(await vwu.aget_api(col_model_url));
|
|
469
|
+
await jqu.subgrid(_id, id, data_url, col_model,'Styles for Process');
|
|
470
|
+
},
|
|
471
|
+
|
|
472
|
+
or
|
|
473
|
+
|
|
474
|
+
subGrid: true,
|
|
475
|
+
subGridRowExpanded: async function(_id, id) {
|
|
476
|
+
let row_data = jQuery(this).jqGrid ('getRowData', id);
|
|
477
|
+
let param={f:'data','style':row_data['style'],pricelist:'P-TENENGR1'};
|
|
478
|
+
let data_url = api + '/order_ln';
|
|
479
|
+
data_url = await add_parameters(data_url, param);
|
|
480
|
+
let col_model_url2 = api + '/order_ln?f=col_model';
|
|
481
|
+
let col_model2 = JSON.parse(await vwu.aget_api(col_model_url2));
|
|
482
|
+
await jqu.subgrid(_id, false, data_url, col_model2,'Order Lines for' + row_data['style']);
|
|
483
|
+
},
|
|
423
484
|
```
|
|
424
485
|
<a name="exp_module_Jqgrid_utils--module.exports+add_image"></a>
|
|
425
486
|
|
package/dist/jqgrid_utils.js
CHANGED
|
@@ -22,10 +22,89 @@ module.exports = class Vanilla_website_utils
|
|
|
22
22
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
{
|
|
@@ -658,14 +738,44 @@ __cell_format(cell_value, format)
|
|
|
658
738
|
@param {object} - col_model for the table
|
|
659
739
|
@param {string} - Add to the caption of the subgrid
|
|
660
740
|
@example
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
let
|
|
741
|
+
subGrid: true,
|
|
742
|
+
,subGridRowExpanded: async function(_id, id) {
|
|
743
|
+
let data_url2 = api + '/process_locations?f=data&process=';
|
|
744
|
+
let col_model_url2 = api + '/process_locations?f=col_model';
|
|
745
|
+
let col_model2 = JSON.parse(await vwu.aget_api(col_model_url2));
|
|
746
|
+
await jqu.subgrid(_id, id, data_url2, col_model2,'Locations for Process');
|
|
747
|
+
|
|
748
|
+
let data_url = api + '/process_styles?f=data&process=';
|
|
749
|
+
let col_model_url = api + '/process_styles?f=col_model';
|
|
750
|
+
let col_model = JSON.parse(await vwu.aget_api(col_model_url));
|
|
751
|
+
await jqu.subgrid(_id, id, data_url, col_model,'Styles for Process');
|
|
752
|
+
},
|
|
753
|
+
|
|
754
|
+
or
|
|
755
|
+
|
|
756
|
+
subGrid: true,
|
|
757
|
+
subGridRowExpanded: async function(_id, id) {
|
|
758
|
+
let row_data = jQuery(this).jqGrid ('getRowData', id);
|
|
759
|
+
let param={f:'data','style':row_data['style'],pricelist:'P-TENENGR1'};
|
|
760
|
+
let data_url = api + '/order_ln';
|
|
761
|
+
data_url = await add_parameters(data_url, param);
|
|
762
|
+
let col_model_url2 = api + '/order_ln?f=col_model';
|
|
763
|
+
let col_model2 = JSON.parse(await vwu.aget_api(col_model_url2));
|
|
764
|
+
await jqu.subgrid(_id, false, data_url, col_model2,'Order Lines for' + row_data['style']);
|
|
765
|
+
},
|
|
766
|
+
|
|
664
767
|
*/
|
|
665
|
-
async subgrid(_id, id,
|
|
768
|
+
async subgrid(_id, id, url, col_model, caption='' )
|
|
666
769
|
{
|
|
667
770
|
caption = caption != '' ? caption + ' ' : '';
|
|
668
|
-
|
|
771
|
+
if(id)
|
|
772
|
+
{
|
|
773
|
+
url += id;
|
|
774
|
+
}
|
|
775
|
+
else
|
|
776
|
+
{
|
|
777
|
+
id = '';
|
|
778
|
+
}
|
|
669
779
|
let $s1 = jQuery("<table style='margin: 5px 0' class='" + _id + "_t'></table>");
|
|
670
780
|
$s1.appendTo("#" + jQuery.jgrid.jqID(_id));
|
|
671
781
|
$s1.jqGrid({
|
package/jqgrid_utils.js
CHANGED
|
@@ -21,10 +21,89 @@ module.exports = class Vanilla_website_utils
|
|
|
21
21
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
{
|
|
@@ -657,14 +737,44 @@ __cell_format(cell_value, format)
|
|
|
657
737
|
@param {object} - col_model for the table
|
|
658
738
|
@param {string} - Add to the caption of the subgrid
|
|
659
739
|
@example
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
let
|
|
740
|
+
subGrid: true,
|
|
741
|
+
,subGridRowExpanded: async function(_id, id) {
|
|
742
|
+
let data_url2 = api + '/process_locations?f=data&process=';
|
|
743
|
+
let col_model_url2 = api + '/process_locations?f=col_model';
|
|
744
|
+
let col_model2 = JSON.parse(await vwu.aget_api(col_model_url2));
|
|
745
|
+
await jqu.subgrid(_id, id, data_url2, col_model2,'Locations for Process');
|
|
746
|
+
|
|
747
|
+
let data_url = api + '/process_styles?f=data&process=';
|
|
748
|
+
let col_model_url = api + '/process_styles?f=col_model';
|
|
749
|
+
let col_model = JSON.parse(await vwu.aget_api(col_model_url));
|
|
750
|
+
await jqu.subgrid(_id, id, data_url, col_model,'Styles for Process');
|
|
751
|
+
},
|
|
752
|
+
|
|
753
|
+
or
|
|
754
|
+
|
|
755
|
+
subGrid: true,
|
|
756
|
+
subGridRowExpanded: async function(_id, id) {
|
|
757
|
+
let row_data = jQuery(this).jqGrid ('getRowData', id);
|
|
758
|
+
let param={f:'data','style':row_data['style'],pricelist:'P-TENENGR1'};
|
|
759
|
+
let data_url = api + '/order_ln';
|
|
760
|
+
data_url = await add_parameters(data_url, param);
|
|
761
|
+
let col_model_url2 = api + '/order_ln?f=col_model';
|
|
762
|
+
let col_model2 = JSON.parse(await vwu.aget_api(col_model_url2));
|
|
763
|
+
await jqu.subgrid(_id, false, data_url, col_model2,'Order Lines for' + row_data['style']);
|
|
764
|
+
},
|
|
765
|
+
|
|
663
766
|
*/
|
|
664
|
-
async subgrid(_id, id,
|
|
767
|
+
async subgrid(_id, id, url, col_model, caption='' )
|
|
665
768
|
{
|
|
666
769
|
caption = caption != '' ? caption + ' ' : '';
|
|
667
|
-
|
|
770
|
+
if(id)
|
|
771
|
+
{
|
|
772
|
+
url += id;
|
|
773
|
+
}
|
|
774
|
+
else
|
|
775
|
+
{
|
|
776
|
+
id = '';
|
|
777
|
+
}
|
|
668
778
|
let $s1 = jQuery("<table style='margin: 5px 0' class='" + _id + "_t'></table>");
|
|
669
779
|
$s1.appendTo("#" + jQuery.jgrid.jqID(_id));
|
|
670
780
|
$s1.jqGrid({
|
package/package.json
CHANGED