jqgrid_utils 1.2.2 → 1.2.5
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 +15 -8
- package/dist/jqgrid_utils.js +44 -14
- package/jqgrid_utils.js +44 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,8 +63,7 @@ A module for Vanilla_website_utils
|
|
|
63
63
|
* [Vanilla_website_utils](#module_Vanilla_website_utils)
|
|
64
64
|
* [module.exports#set_link()](#exp_module_Vanilla_website_utils--module.exports+set_link) ⏏
|
|
65
65
|
* [module.exports#grid_set_captain()](#exp_module_Vanilla_website_utils--module.exports+grid_set_captain) ⏏
|
|
66
|
-
* [module.exports#resize_saved_cell_width()](#exp_module_Vanilla_website_utils--module.exports+resize_saved_cell_width) ⏏
|
|
67
|
-
* [module.exports#resize_cell()](#exp_module_Vanilla_website_utils--module.exports+resize_cell) ⏏
|
|
66
|
+
* [module.exports#resize_saved_cell_width(col_model, page, grid)](#exp_module_Vanilla_website_utils--module.exports+resize_saved_cell_width) ⏏
|
|
68
67
|
* [module.exports#upsert_row()](#exp_module_Vanilla_website_utils--module.exports+upsert_row) ⏏
|
|
69
68
|
* [module.exports#insert_row()](#exp_module_Vanilla_website_utils--module.exports+insert_row) ⏏
|
|
70
69
|
* [module.exports#update_row()](#exp_module_Vanilla_website_utils--module.exports+update_row) ⏏
|
|
@@ -76,7 +75,7 @@ A module for Vanilla_website_utils
|
|
|
76
75
|
* [module.exports#add_link_details()](#exp_module_Vanilla_website_utils--module.exports+add_link_details) ⏏
|
|
77
76
|
* [module.exports#add_link_details_separator()](#exp_module_Vanilla_website_utils--module.exports+add_link_details_separator) ⏏
|
|
78
77
|
* [module.exports#__cell_format()](#exp_module_Vanilla_website_utils--module.exports+__cell_format) ⏏
|
|
79
|
-
* [module.exports#subgrid(_id, id, data_url)](#exp_module_Vanilla_website_utils--module.exports+subgrid) ⏏
|
|
78
|
+
* [module.exports#subgrid(_id, id, data_url, col_model)](#exp_module_Vanilla_website_utils--module.exports+subgrid) ⏏
|
|
80
79
|
* [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Vanilla_website_utils--module.exports+add_image) ⏏
|
|
81
80
|
|
|
82
81
|
<a name="exp_module_Vanilla_website_utils--module.exports+set_link"></a>
|
|
@@ -89,12 +88,19 @@ A module for Vanilla_website_utils
|
|
|
89
88
|
**Kind**: Exported function
|
|
90
89
|
<a name="exp_module_Vanilla_website_utils--module.exports+resize_saved_cell_width"></a>
|
|
91
90
|
|
|
92
|
-
### module.exports#resize\_saved\_cell\_width() ⏏
|
|
91
|
+
### module.exports#resize\_saved\_cell\_width(col_model, page, grid) ⏏
|
|
93
92
|
**Kind**: Exported function
|
|
94
|
-
<a name="exp_module_Vanilla_website_utils--module.exports+resize_cell"></a>
|
|
95
93
|
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
| Param | Type | Default | Description |
|
|
95
|
+
| --- | --- | --- | --- |
|
|
96
|
+
| col_model | <code>object</code> | | col_model for the grid |
|
|
97
|
+
| page | <code>string</code> | <code>false</code> | page |
|
|
98
|
+
| grid | <code>object</code> | <code>false</code> | grid |
|
|
99
|
+
|
|
100
|
+
**Example**
|
|
101
|
+
```js
|
|
102
|
+
col_model = await jqu.resize_saved_cell_width(col_model);
|
|
103
|
+
```
|
|
98
104
|
<a name="exp_module_Vanilla_website_utils--module.exports+upsert_row"></a>
|
|
99
105
|
|
|
100
106
|
### module.exports#upsert\_row() ⏏
|
|
@@ -149,7 +155,7 @@ A module for Vanilla_website_utils
|
|
|
149
155
|
**Kind**: Exported function
|
|
150
156
|
<a name="exp_module_Vanilla_website_utils--module.exports+subgrid"></a>
|
|
151
157
|
|
|
152
|
-
### module.exports#subgrid(_id, id, data_url) ⏏
|
|
158
|
+
### module.exports#subgrid(_id, id, data_url, col_model) ⏏
|
|
153
159
|
**Kind**: Exported function
|
|
154
160
|
|
|
155
161
|
| Param | Type | Description |
|
|
@@ -157,6 +163,7 @@ A module for Vanilla_website_utils
|
|
|
157
163
|
| _id | <code>string</code> | row_id |
|
|
158
164
|
| id | <code>string</code> | data id |
|
|
159
165
|
| data_url | <code>object</code> | col_model for the table |
|
|
166
|
+
| col_model | <code>string</code> | Caption |
|
|
160
167
|
|
|
161
168
|
**Example**
|
|
162
169
|
```js
|
package/dist/jqgrid_utils.js
CHANGED
|
@@ -78,8 +78,15 @@ module.exports = class Vanilla_website_utils
|
|
|
78
78
|
{
|
|
79
79
|
this.grid_set_captain(col_model, page, grid);
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
|
|
81
83
|
/**
|
|
82
84
|
@alias module:Vanilla_website_utils
|
|
85
|
+
@param {object} - col_model for the grid
|
|
86
|
+
@param {string} - page
|
|
87
|
+
@param {object} - grid
|
|
88
|
+
@example
|
|
89
|
+
* col_model = await jqu.resize_saved_cell_width(col_model);
|
|
83
90
|
*/
|
|
84
91
|
async resize_saved_cell_width(col_model,page=false, grid=false)
|
|
85
92
|
{
|
|
@@ -87,10 +94,17 @@ module.exports = class Vanilla_website_utils
|
|
|
87
94
|
key += grid ? '-' + grid + '-w-' : '-grid-w-';
|
|
88
95
|
for(let x = 0; x<= col_model.length; x++)
|
|
89
96
|
{
|
|
90
|
-
|
|
91
|
-
if(width)
|
|
97
|
+
if(col_model[x])
|
|
92
98
|
{
|
|
93
|
-
col_model[x]['
|
|
99
|
+
if(col_model[x]['name'])
|
|
100
|
+
{
|
|
101
|
+
const name = col_model[x]['name'];
|
|
102
|
+
const width = localStorage.getItem(key + name);
|
|
103
|
+
if(width)
|
|
104
|
+
{
|
|
105
|
+
col_model[x]['width'] = width;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
return col_model;
|
|
@@ -98,16 +112,30 @@ module.exports = class Vanilla_website_utils
|
|
|
98
112
|
|
|
99
113
|
/**
|
|
100
114
|
@alias module:Vanilla_website_utils
|
|
115
|
+
* resize_cell
|
|
116
|
+
* call after resize a column
|
|
117
|
+
@param {string} - width - the size of the resized column
|
|
118
|
+
@param {string} - index - column number what get resized
|
|
119
|
+
@param {string} - _page - not in use yet
|
|
120
|
+
@example
|
|
121
|
+
* var jqu = new Jqgrid_utils({page:'mypage'});
|
|
122
|
+
* resizeStop: jqu.resize_cell,
|
|
101
123
|
*/
|
|
102
124
|
resize_cell(width, index, _page=false)
|
|
103
125
|
{
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
126
|
+
const col_model = jQuery(this).jqGrid ('getGridParam', 'colModel');
|
|
127
|
+
if(col_model[index])
|
|
128
|
+
{
|
|
129
|
+
if(col_model[index]['name'])
|
|
130
|
+
{
|
|
131
|
+
const name = col_model[index]['name'];
|
|
132
|
+
const page = _page ? _page : localStorage.getItem('page');
|
|
133
|
+
const grid = this.id;
|
|
134
|
+
let key = page + '-' + grid + '-w-' + name;
|
|
135
|
+
localStorage.setItem(key, width);
|
|
136
|
+
const cat = localStorage.getItem(key);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
111
139
|
}
|
|
112
140
|
|
|
113
141
|
|
|
@@ -427,17 +455,20 @@ __cell_format(cell_value, format)
|
|
|
427
455
|
@param {string} - row_id
|
|
428
456
|
@param {string} - data id
|
|
429
457
|
@param {object} - col_model for the table
|
|
458
|
+
@param {string} - Caption
|
|
430
459
|
@example
|
|
431
460
|
* let data_url = api + '/phone_detail?f=data&_id=';
|
|
432
461
|
* let col_model_url = api + '/phone_detail?f=col_model';
|
|
433
462
|
* let col_model = JSON.parse(await vwu.aget_api(col_model_url))
|
|
434
463
|
*/
|
|
435
|
-
async subgrid(_id, id, data_url, col_model)
|
|
464
|
+
async subgrid(_id, id, data_url, col_model, caption='' )
|
|
436
465
|
{
|
|
466
|
+
caption = caption != '' ? caption + ' ' : '';
|
|
437
467
|
let url = data_url + id;
|
|
438
|
-
let $s1 = jQuery("<table
|
|
468
|
+
let $s1 = jQuery("<table style='margin: 5px 0' class='" + _id + "_t'></table>");
|
|
439
469
|
$s1.appendTo("#" + jQuery.jgrid.jqID(_id));
|
|
440
470
|
$s1.jqGrid({
|
|
471
|
+
caption: caption + id,
|
|
441
472
|
colModel: col_model,
|
|
442
473
|
datatype: "json",
|
|
443
474
|
url: url,
|
|
@@ -445,8 +476,7 @@ async subgrid(_id, id, data_url, col_model)
|
|
|
445
476
|
rownumbers: true,
|
|
446
477
|
autoencode: true,
|
|
447
478
|
sortname: "c1",
|
|
448
|
-
sortorder: "desc"
|
|
449
|
-
caption: id
|
|
479
|
+
sortorder: "desc"
|
|
450
480
|
});
|
|
451
481
|
}
|
|
452
482
|
|
package/jqgrid_utils.js
CHANGED
|
@@ -77,8 +77,15 @@ module.exports = class Vanilla_website_utils
|
|
|
77
77
|
{
|
|
78
78
|
this.grid_set_captain(col_model, page, grid);
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
|
|
80
82
|
/**
|
|
81
83
|
@alias module:Vanilla_website_utils
|
|
84
|
+
@param {object} - col_model for the grid
|
|
85
|
+
@param {string} - page
|
|
86
|
+
@param {object} - grid
|
|
87
|
+
@example
|
|
88
|
+
* col_model = await jqu.resize_saved_cell_width(col_model);
|
|
82
89
|
*/
|
|
83
90
|
async resize_saved_cell_width(col_model,page=false, grid=false)
|
|
84
91
|
{
|
|
@@ -86,10 +93,17 @@ module.exports = class Vanilla_website_utils
|
|
|
86
93
|
key += grid ? '-' + grid + '-w-' : '-grid-w-';
|
|
87
94
|
for(let x = 0; x<= col_model.length; x++)
|
|
88
95
|
{
|
|
89
|
-
|
|
90
|
-
if(width)
|
|
96
|
+
if(col_model[x])
|
|
91
97
|
{
|
|
92
|
-
col_model[x]['
|
|
98
|
+
if(col_model[x]['name'])
|
|
99
|
+
{
|
|
100
|
+
const name = col_model[x]['name'];
|
|
101
|
+
const width = localStorage.getItem(key + name);
|
|
102
|
+
if(width)
|
|
103
|
+
{
|
|
104
|
+
col_model[x]['width'] = width;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
93
107
|
}
|
|
94
108
|
}
|
|
95
109
|
return col_model;
|
|
@@ -97,16 +111,30 @@ module.exports = class Vanilla_website_utils
|
|
|
97
111
|
|
|
98
112
|
/**
|
|
99
113
|
@alias module:Vanilla_website_utils
|
|
114
|
+
* resize_cell
|
|
115
|
+
* call after resize a column
|
|
116
|
+
@param {string} - width - the size of the resized column
|
|
117
|
+
@param {string} - index - column number what get resized
|
|
118
|
+
@param {string} - _page - not in use yet
|
|
119
|
+
@example
|
|
120
|
+
* var jqu = new Jqgrid_utils({page:'mypage'});
|
|
121
|
+
* resizeStop: jqu.resize_cell,
|
|
100
122
|
*/
|
|
101
123
|
resize_cell(width, index, _page=false)
|
|
102
124
|
{
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
125
|
+
const col_model = jQuery(this).jqGrid ('getGridParam', 'colModel');
|
|
126
|
+
if(col_model[index])
|
|
127
|
+
{
|
|
128
|
+
if(col_model[index]['name'])
|
|
129
|
+
{
|
|
130
|
+
const name = col_model[index]['name'];
|
|
131
|
+
const page = _page ? _page : localStorage.getItem('page');
|
|
132
|
+
const grid = this.id;
|
|
133
|
+
let key = page + '-' + grid + '-w-' + name;
|
|
134
|
+
localStorage.setItem(key, width);
|
|
135
|
+
const cat = localStorage.getItem(key);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
110
138
|
}
|
|
111
139
|
|
|
112
140
|
|
|
@@ -426,17 +454,20 @@ __cell_format(cell_value, format)
|
|
|
426
454
|
@param {string} - row_id
|
|
427
455
|
@param {string} - data id
|
|
428
456
|
@param {object} - col_model for the table
|
|
457
|
+
@param {string} - Caption
|
|
429
458
|
@example
|
|
430
459
|
* let data_url = api + '/phone_detail?f=data&_id=';
|
|
431
460
|
* let col_model_url = api + '/phone_detail?f=col_model';
|
|
432
461
|
* let col_model = JSON.parse(await vwu.aget_api(col_model_url))
|
|
433
462
|
*/
|
|
434
|
-
async subgrid(_id, id, data_url, col_model)
|
|
463
|
+
async subgrid(_id, id, data_url, col_model, caption='' )
|
|
435
464
|
{
|
|
465
|
+
caption = caption != '' ? caption + ' ' : '';
|
|
436
466
|
let url = data_url + id;
|
|
437
|
-
let $s1 = jQuery("<table
|
|
467
|
+
let $s1 = jQuery("<table style='margin: 5px 0' class='" + _id + "_t'></table>");
|
|
438
468
|
$s1.appendTo("#" + jQuery.jgrid.jqID(_id));
|
|
439
469
|
$s1.jqGrid({
|
|
470
|
+
caption: caption + id,
|
|
440
471
|
colModel: col_model,
|
|
441
472
|
datatype: "json",
|
|
442
473
|
url: url,
|
|
@@ -444,8 +475,7 @@ async subgrid(_id, id, data_url, col_model)
|
|
|
444
475
|
rownumbers: true,
|
|
445
476
|
autoencode: true,
|
|
446
477
|
sortname: "c1",
|
|
447
|
-
sortorder: "desc"
|
|
448
|
-
caption: id
|
|
478
|
+
sortorder: "desc"
|
|
449
479
|
});
|
|
450
480
|
}
|
|
451
481
|
|
package/package.json
CHANGED