jqgrid_utils 1.2.15 → 1.2.18
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 +219 -25
- package/dist/jqgrid_utils.js +122 -6
- package/jqgrid_utils.js +122 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,21 +36,23 @@ A module for Jqgrid_utils
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
* [Jqgrid_utils](#module_Jqgrid_utils)
|
|
39
|
-
* [module.exports#set_link(col_model, edit_field, url)](#exp_module_Jqgrid_utils--module.exports+set_link) ⏏
|
|
39
|
+
* [module.exports#set_link(col_model, edit_field, url)](#exp_module_Jqgrid_utils--module.exports+set_link) ⇒ <code>string</code> ⏏
|
|
40
|
+
* [module.exports#s_grid_set_caption(_grid, data)](#exp_module_Jqgrid_utils--module.exports+s_grid_set_caption) ⏏
|
|
40
41
|
* [module.exports#grid_set_caption(_grid, data)](#exp_module_Jqgrid_utils--module.exports+grid_set_caption) ⏏
|
|
41
|
-
* [module.exports#s_resize_saved_cell_width()](#exp_module_Jqgrid_utils--module.exports+s_resize_saved_cell_width) ⏏
|
|
42
|
+
* [module.exports#s_resize_saved_cell_width(col_model, page, grid)](#exp_module_Jqgrid_utils--module.exports+s_resize_saved_cell_width) ⏏
|
|
42
43
|
* [module.exports#resize_saved_cell_width(col_model, page, grid)](#exp_module_Jqgrid_utils--module.exports+resize_saved_cell_width) ⏏
|
|
43
44
|
* [module.exports#resize_cell(the, column, not)](#exp_module_Jqgrid_utils--module.exports+resize_cell) ⏏
|
|
44
|
-
* [module.exports#upsert_row()](#exp_module_Jqgrid_utils--module.exports+upsert_row) ⏏
|
|
45
|
-
* [module.exports#insert_row()](#exp_module_Jqgrid_utils--module.exports+insert_row) ⏏
|
|
46
|
-
* [module.exports#update_row()](#exp_module_Jqgrid_utils--module.exports+update_row) ⏏
|
|
47
|
-
* [module.exports#delete_row()](#exp_module_Jqgrid_utils--module.exports+delete_row) ⏏
|
|
48
|
-
* [module.exports#adelete_api()](#exp_module_Jqgrid_utils--module.exports+adelete_api) ⏏
|
|
49
|
-
* [module.exports#post_json()](#exp_module_Jqgrid_utils--module.exports+post_json) ⏏
|
|
50
|
-
* [module.exports#put_json()](#exp_module_Jqgrid_utils--module.exports+put_json) ⏏
|
|
45
|
+
* [module.exports#upsert_row(row, url, req)](#exp_module_Jqgrid_utils--module.exports+upsert_row) ⇒ <code>object</code> ⏏
|
|
46
|
+
* [module.exports#insert_row(row, url)](#exp_module_Jqgrid_utils--module.exports+insert_row) ⇒ <code>object</code> ⏏
|
|
47
|
+
* [module.exports#update_row(row, url, req)](#exp_module_Jqgrid_utils--module.exports+update_row) ⇒ <code>object</code> ⏏
|
|
48
|
+
* [module.exports#delete_row(_id, url)](#exp_module_Jqgrid_utils--module.exports+delete_row) ⇒ <code>object</code> ⏏
|
|
49
|
+
* [module.exports#adelete_api(url)](#exp_module_Jqgrid_utils--module.exports+adelete_api) ⇒ <code>object</code> ⏏
|
|
50
|
+
* [module.exports#post_json(url, data)](#exp_module_Jqgrid_utils--module.exports+post_json) ⇒ <code>object</code> ⏏
|
|
51
|
+
* [module.exports#put_json(url, data)](#exp_module_Jqgrid_utils--module.exports+put_json) ⇒ <code>object</code> ⏏
|
|
52
|
+
* [module.exports#s_hide_del_icon()](#exp_module_Jqgrid_utils--module.exports+s_hide_del_icon) ⏏
|
|
51
53
|
* [module.exports#hide_del_icon()](#exp_module_Jqgrid_utils--module.exports+hide_del_icon) ⏏
|
|
52
|
-
* [module.exports#add_link_details()](#exp_module_Jqgrid_utils--module.exports+add_link_details) ⏏
|
|
53
|
-
* [module.exports#add_link_details_separator()](#exp_module_Jqgrid_utils--module.exports+add_link_details_separator) ⏏
|
|
54
|
+
* [module.exports#add_link_details(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details) ⏏
|
|
55
|
+
* [module.exports#add_link_details_separator(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details_separator) ⏏
|
|
54
56
|
* [module.exports#__cell_format()](#exp_module_Jqgrid_utils--module.exports+__cell_format) ⏏
|
|
55
57
|
* [module.exports#subgrid(_id, id, data_url, col_model, caption)](#exp_module_Jqgrid_utils--module.exports+subgrid) ⏏
|
|
56
58
|
* [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Jqgrid_utils--module.exports+add_image) ⏏
|
|
@@ -59,11 +61,11 @@ A module for Jqgrid_utils
|
|
|
59
61
|
|
|
60
62
|
<a name="exp_module_Jqgrid_utils--module.exports+set_link"></a>
|
|
61
63
|
|
|
62
|
-
### module.exports#set\_link(col_model, edit_field, url) ⏏
|
|
64
|
+
### module.exports#set\_link(col_model, edit_field, url) ⇒ <code>string</code> ⏏
|
|
63
65
|
Add an URL from the data to a specific cell/column
|
|
64
66
|
|
|
65
67
|
**Kind**: Exported function
|
|
66
|
-
**
|
|
68
|
+
**Returns**: <code>string</code> - https://foo.bar.com/av0_code/bar
|
|
67
69
|
|
|
68
70
|
| Param | Type | Description |
|
|
69
71
|
| --- | --- | --- |
|
|
@@ -73,8 +75,26 @@ Add an URL from the data to a specific cell/column
|
|
|
73
75
|
|
|
74
76
|
**Example**
|
|
75
77
|
```js
|
|
78
|
+
var jqu = new Jqgrid_utils();
|
|
76
79
|
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
|
|
77
80
|
```
|
|
81
|
+
<a name="exp_module_Jqgrid_utils--module.exports+s_grid_set_caption"></a>
|
|
82
|
+
|
|
83
|
+
### module.exports#s\_grid\_set\_caption(_grid, data) ⏏
|
|
84
|
+
**Kind**: Exported function
|
|
85
|
+
|
|
86
|
+
| Param | Type | Description |
|
|
87
|
+
| --- | --- | --- |
|
|
88
|
+
| _grid | <code>object</code> | gridobject; |
|
|
89
|
+
| data | <code>object</code> | grid data (optional); |
|
|
90
|
+
|
|
91
|
+
**Example**
|
|
92
|
+
```js
|
|
93
|
+
var jqu = new Jqgrid_utils();
|
|
94
|
+
loadComplete: function(){
|
|
95
|
+
jqu.grid_set_caption(this);
|
|
96
|
+
},
|
|
97
|
+
```
|
|
78
98
|
<a name="exp_module_Jqgrid_utils--module.exports+grid_set_caption"></a>
|
|
79
99
|
|
|
80
100
|
### module.exports#grid\_set\_caption(_grid, data) ⏏
|
|
@@ -89,13 +109,24 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
|
|
|
89
109
|
```js
|
|
90
110
|
var jqu = new Jqgrid_utils();
|
|
91
111
|
loadComplete: function(){
|
|
92
|
-
jqu.grid_set_caption(this);
|
|
112
|
+
await jqu.grid_set_caption(this);
|
|
93
113
|
},
|
|
94
114
|
```
|
|
95
115
|
<a name="exp_module_Jqgrid_utils--module.exports+s_resize_saved_cell_width"></a>
|
|
96
116
|
|
|
97
|
-
### module.exports#s\_resize\_saved\_cell\_width() ⏏
|
|
117
|
+
### module.exports#s\_resize\_saved\_cell\_width(col_model, page, grid) ⏏
|
|
98
118
|
**Kind**: Exported function
|
|
119
|
+
|
|
120
|
+
| Param | Type | Default | Description |
|
|
121
|
+
| --- | --- | --- | --- |
|
|
122
|
+
| col_model | <code>object</code> | | the col_model of the grid |
|
|
123
|
+
| page | <code>string</code> | <code>false</code> | the name of the page(optional) |
|
|
124
|
+
| grid | <code>object</code> | <code>false</code> | the grid objec(optional) |
|
|
125
|
+
|
|
126
|
+
**Example**
|
|
127
|
+
```js
|
|
128
|
+
col_model = await jqu.resize_saved_cell_width(col_model);
|
|
129
|
+
```
|
|
99
130
|
<a name="exp_module_Jqgrid_utils--module.exports+resize_saved_cell_width"></a>
|
|
100
131
|
|
|
101
132
|
### module.exports#resize\_saved\_cell\_width(col_model, page, grid) ⏏
|
|
@@ -129,55 +160,218 @@ resizeStop: jqu.resize_cell,
|
|
|
129
160
|
```
|
|
130
161
|
<a name="exp_module_Jqgrid_utils--module.exports+upsert_row"></a>
|
|
131
162
|
|
|
132
|
-
### module.exports#upsert\_row() ⏏
|
|
163
|
+
### module.exports#upsert\_row(row, url, req) ⇒ <code>object</code> ⏏
|
|
164
|
+
Upsert(insert or update) from the grid to an API
|
|
165
|
+
|
|
133
166
|
**Kind**: Exported function
|
|
167
|
+
**Returns**: <code>object</code> - {update: 'ok'} or {udpate: 'failed'}
|
|
168
|
+
|
|
169
|
+
| Param | Type | Description |
|
|
170
|
+
| --- | --- | --- |
|
|
171
|
+
| row | <code>object</code> | row object |
|
|
172
|
+
| url | <code>string</code> | url of the API |
|
|
173
|
+
| req | <code>string</code> | data oject |
|
|
174
|
+
|
|
175
|
+
**Example**
|
|
176
|
+
```js
|
|
177
|
+
var jqu = new Jqgrid_utils();
|
|
178
|
+
afterSetRow: async function(row)
|
|
179
|
+
{
|
|
180
|
+
let r = await jqu.upsert_row(row, url);
|
|
181
|
+
console.log(r);
|
|
182
|
+
},
|
|
183
|
+
```
|
|
134
184
|
<a name="exp_module_Jqgrid_utils--module.exports+insert_row"></a>
|
|
135
185
|
|
|
136
|
-
### module.exports#insert\_row() ⏏
|
|
186
|
+
### module.exports#insert\_row(row, url) ⇒ <code>object</code> ⏏
|
|
187
|
+
Insert from the grid to an API used by the upsert_row function
|
|
188
|
+
|
|
137
189
|
**Kind**: Exported function
|
|
190
|
+
**Returns**: <code>object</code> - Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
191
|
+
|
|
192
|
+
| Param | Type | Description |
|
|
193
|
+
| --- | --- | --- |
|
|
194
|
+
| row | <code>object</code> | row object |
|
|
195
|
+
| url | <code>string</code> | url of the API |
|
|
196
|
+
| | <code>string</code> | data oject |
|
|
197
|
+
|
|
198
|
+
**Example**
|
|
199
|
+
```js
|
|
200
|
+
var jqu = new Jqgrid_utils();
|
|
201
|
+
afterSetRow: async function(row)
|
|
202
|
+
{
|
|
203
|
+
let r = await jqu.upsert_row(row, url);
|
|
204
|
+
console.log(r);
|
|
205
|
+
},
|
|
206
|
+
```
|
|
138
207
|
<a name="exp_module_Jqgrid_utils--module.exports+update_row"></a>
|
|
139
208
|
|
|
140
|
-
### module.exports#update\_row() ⏏
|
|
209
|
+
### module.exports#update\_row(row, url, req) ⇒ <code>object</code> ⏏
|
|
210
|
+
Update from the grid to an API used by the upsert_row function
|
|
211
|
+
|
|
141
212
|
**Kind**: Exported function
|
|
213
|
+
**Returns**: <code>object</code> - Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
214
|
+
|
|
215
|
+
| Param | Type | Description |
|
|
216
|
+
| --- | --- | --- |
|
|
217
|
+
| row | <code>object</code> | row object |
|
|
218
|
+
| url | <code>string</code> | url of the API |
|
|
219
|
+
| req | <code>string</code> | data oject |
|
|
220
|
+
|
|
221
|
+
**Example**
|
|
222
|
+
```js
|
|
223
|
+
var jqu = new Jqgrid_utils();
|
|
224
|
+
afterSetRow: async function(row)
|
|
225
|
+
{
|
|
226
|
+
let r = await jqu.upsert_row(row, url);
|
|
227
|
+
console.log(r);
|
|
228
|
+
},
|
|
229
|
+
```
|
|
142
230
|
<a name="exp_module_Jqgrid_utils--module.exports+delete_row"></a>
|
|
143
231
|
|
|
144
|
-
### module.exports#delete\_row() ⏏
|
|
232
|
+
### module.exports#delete\_row(_id, url) ⇒ <code>object</code> ⏏
|
|
233
|
+
Delete from the grid to an API
|
|
234
|
+
|
|
145
235
|
**Kind**: Exported function
|
|
236
|
+
**Returns**: <code>object</code> - @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
237
|
+
|
|
238
|
+
| Param | Type | Description |
|
|
239
|
+
| --- | --- | --- |
|
|
240
|
+
| _id | <code>string</code> | row id |
|
|
241
|
+
| url | <code>string</code> | url of the API |
|
|
242
|
+
|
|
243
|
+
**Example**
|
|
244
|
+
```js
|
|
245
|
+
var jqu = new Jqgrid_utils();
|
|
246
|
+
afterDelRow: async function(row)
|
|
247
|
+
{
|
|
248
|
+
const r = await jqu.delete_row(row, url);
|
|
249
|
+
console.log(r + ' : ' + row + ' - from API');
|
|
250
|
+
},
|
|
251
|
+
```
|
|
146
252
|
<a name="exp_module_Jqgrid_utils--module.exports+adelete_api"></a>
|
|
147
253
|
|
|
148
|
-
### module.exports#adelete\_api() ⏏
|
|
254
|
+
### module.exports#adelete\_api(url) ⇒ <code>object</code> ⏏
|
|
255
|
+
Async Delete request used by function delete_row
|
|
256
|
+
|
|
149
257
|
**Kind**: Exported function
|
|
258
|
+
**Returns**: <code>object</code> - @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
259
|
+
|
|
260
|
+
| Param | Type | Description |
|
|
261
|
+
| --- | --- | --- |
|
|
262
|
+
| url | <code>string</code> | url of the API |
|
|
263
|
+
|
|
264
|
+
**Example**
|
|
265
|
+
```js
|
|
266
|
+
var jqu = new Jqgrid_utils();
|
|
267
|
+
afterDelRow: async function(row)
|
|
268
|
+
{
|
|
269
|
+
ret = JSON.parse(await jqu.adelete_api(url));
|
|
270
|
+
},
|
|
271
|
+
```
|
|
150
272
|
<a name="exp_module_Jqgrid_utils--module.exports+post_json"></a>
|
|
151
273
|
|
|
152
|
-
### module.exports#post\_json() ⏏
|
|
274
|
+
### module.exports#post\_json(url, data) ⇒ <code>object</code> ⏏
|
|
275
|
+
Async Post request used by the update_row function
|
|
276
|
+
|
|
153
277
|
**Kind**: Exported function
|
|
278
|
+
**Returns**: <code>object</code> - @returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
279
|
+
|
|
280
|
+
| Param | Type | Description |
|
|
281
|
+
| --- | --- | --- |
|
|
282
|
+
| url | <code>string</code> | url of the API |
|
|
283
|
+
| data | <code>object</code> | json object |
|
|
284
|
+
|
|
285
|
+
**Example**
|
|
286
|
+
```js
|
|
287
|
+
var jqu = new Jqgrid_utils();
|
|
288
|
+
ret = JSON.parse(await jqu.post_json(url,{'key':value,'key2':'value'}));
|
|
289
|
+
```
|
|
154
290
|
<a name="exp_module_Jqgrid_utils--module.exports+put_json"></a>
|
|
155
291
|
|
|
156
|
-
### module.exports#put\_json() ⏏
|
|
292
|
+
### module.exports#put\_json(url, data) ⇒ <code>object</code> ⏏
|
|
293
|
+
Async Put request used by the insert_row function
|
|
294
|
+
|
|
157
295
|
**Kind**: Exported function
|
|
296
|
+
**Returns**: <code>object</code> - @returns {object} Object from the the API like {insert: 'ok'} or {insert: 'failed'}
|
|
297
|
+
|
|
298
|
+
| Param | Type | Description |
|
|
299
|
+
| --- | --- | --- |
|
|
300
|
+
| url | <code>string</code> | url of the API |
|
|
301
|
+
| data | <code>object</code> | json object |
|
|
302
|
+
|
|
303
|
+
**Example**
|
|
304
|
+
```js
|
|
305
|
+
var jqu = new Jqgrid_utils();
|
|
306
|
+
ret = JSON.parse(await jqu.put_json(url,{'key':value,'key2':'value2'}));
|
|
307
|
+
```
|
|
308
|
+
<a name="exp_module_Jqgrid_utils--module.exports+s_hide_del_icon"></a>
|
|
309
|
+
|
|
310
|
+
### module.exports#s\_hide\_del\_icon() ⏏
|
|
311
|
+
Hide the del iconf rom the grid
|
|
312
|
+
|
|
313
|
+
**Kind**: Exported function
|
|
314
|
+
**Example**
|
|
315
|
+
```js
|
|
316
|
+
var jqu = new Jqgrid_utils();
|
|
317
|
+
jqu.hide_del_icon();
|
|
318
|
+
```
|
|
158
319
|
<a name="exp_module_Jqgrid_utils--module.exports+hide_del_icon"></a>
|
|
159
320
|
|
|
160
321
|
### module.exports#hide\_del\_icon() ⏏
|
|
322
|
+
Hide the del iconf rom the grid
|
|
323
|
+
|
|
161
324
|
**Kind**: Exported function
|
|
325
|
+
**Example**
|
|
326
|
+
```js
|
|
327
|
+
var jqu = new Jqgrid_utils();
|
|
328
|
+
await jqu.hide_del_icon();
|
|
329
|
+
```
|
|
162
330
|
<a name="exp_module_Jqgrid_utils--module.exports+add_link_details"></a>
|
|
163
331
|
|
|
164
|
-
### module.exports#add\_link\_details() ⏏
|
|
332
|
+
### module.exports#add\_link\_details(col_model, url, edit_field, attr, keys) ⏏
|
|
333
|
+
Convert a cell into a link/url with data from another cell
|
|
334
|
+
|
|
165
335
|
**Kind**: Exported function
|
|
336
|
+
|
|
337
|
+
| Param | Type | Description |
|
|
338
|
+
| --- | --- | --- |
|
|
339
|
+
| col_model | <code>object</code> | col_model of the grid |
|
|
340
|
+
| url | <code>string</code> | URL string |
|
|
341
|
+
| edit_field | <code>string</code> | Column/Cell to use |
|
|
342
|
+
| attr | <code>string</code> | URL Attributes |
|
|
343
|
+
| keys | <code>object</code> | keys and fields value to use |
|
|
344
|
+
|
|
166
345
|
**Example**
|
|
167
346
|
```js
|
|
168
|
-
|
|
347
|
+
var jqu = new Jqgrid_utils();
|
|
348
|
+
col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
|
|
169
349
|
```
|
|
170
350
|
<a name="exp_module_Jqgrid_utils--module.exports+add_link_details_separator"></a>
|
|
171
351
|
|
|
172
|
-
### module.exports#add\_link\_details\_separator() ⏏
|
|
352
|
+
### module.exports#add\_link\_details\_separator(col_model, url, edit_field, attr, keys) ⏏
|
|
353
|
+
Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
|
|
354
|
+
|
|
173
355
|
**Kind**: Exported function
|
|
356
|
+
|
|
357
|
+
| Param | Type | Description |
|
|
358
|
+
| --- | --- | --- |
|
|
359
|
+
| col_model | <code>object</code> | col_model of the grid |
|
|
360
|
+
| url | <code>string</code> | URL string |
|
|
361
|
+
| edit_field | <code>string</code> | Column/Cell to use |
|
|
362
|
+
| attr | <code>string</code> | URL Attributes |
|
|
363
|
+
| keys | <code>object</code> | keys and fields value to use |
|
|
364
|
+
|
|
174
365
|
**Example**
|
|
175
366
|
```js
|
|
367
|
+
var jqu = new Jqgrid_utils();
|
|
176
368
|
col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
|
|
177
369
|
```
|
|
178
370
|
<a name="exp_module_Jqgrid_utils--module.exports+__cell_format"></a>
|
|
179
371
|
|
|
180
372
|
### module.exports#\_\_cell\_format() ⏏
|
|
373
|
+
Private Function
|
|
374
|
+
|
|
181
375
|
**Kind**: Exported function
|
|
182
376
|
<a name="exp_module_Jqgrid_utils--module.exports+subgrid"></a>
|
|
183
377
|
|
package/dist/jqgrid_utils.js
CHANGED
|
@@ -33,10 +33,10 @@ module.exports = class Vanilla_website_utils
|
|
|
33
33
|
@param {object} - col_model of the grid
|
|
34
34
|
@param {string} - name of the column what should get convert to the url
|
|
35
35
|
@param {string} - the used url of the data
|
|
36
|
+
@returns {string} https://foo.bar.com/av0_code/bar
|
|
36
37
|
@example
|
|
38
|
+
var jqu = new Jqgrid_utils();
|
|
37
39
|
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
|
|
38
|
-
@result
|
|
39
|
-
* https://foo.bar.com/av0_code/bar
|
|
40
40
|
*/
|
|
41
41
|
async set_link(col_model, edit_field, url ,attr='')
|
|
42
42
|
{
|
|
@@ -53,6 +53,16 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
|
|
|
53
53
|
return col_model;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
@alias module:Jqgrid_utils
|
|
58
|
+
@param {object} - gridobject;
|
|
59
|
+
@param {object} - grid data (optional);
|
|
60
|
+
@example
|
|
61
|
+
var jqu = new Jqgrid_utils();
|
|
62
|
+
loadComplete: function(){
|
|
63
|
+
jqu.grid_set_caption(this);
|
|
64
|
+
},
|
|
65
|
+
*/
|
|
56
66
|
|
|
57
67
|
s_grid_set_caption(_grid, data=[])
|
|
58
68
|
{
|
|
@@ -66,7 +76,7 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
|
|
|
66
76
|
@example
|
|
67
77
|
var jqu = new Jqgrid_utils();
|
|
68
78
|
loadComplete: function(){
|
|
69
|
-
jqu.grid_set_caption(this);
|
|
79
|
+
await jqu.grid_set_caption(this);
|
|
70
80
|
},
|
|
71
81
|
*/
|
|
72
82
|
async grid_set_caption(_grid, data=[])
|
|
@@ -89,6 +99,11 @@ loadComplete: function(){
|
|
|
89
99
|
|
|
90
100
|
/**
|
|
91
101
|
@alias module:Jqgrid_utils
|
|
102
|
+
@param {object} - the col_model of the grid
|
|
103
|
+
@param {string} - the name of the page(optional)
|
|
104
|
+
@param {object} - the grid objec(optional)
|
|
105
|
+
@example
|
|
106
|
+
col_model = await jqu.resize_saved_cell_width(col_model);
|
|
92
107
|
*/
|
|
93
108
|
s_resize_saved_cell_width(col_model, page=false, grid=false)
|
|
94
109
|
{
|
|
@@ -155,7 +170,19 @@ col_model = await jqu.resize_saved_cell_width(col_model);
|
|
|
155
170
|
|
|
156
171
|
|
|
157
172
|
/**
|
|
173
|
+
* Upsert(insert or update) from the grid to an API
|
|
158
174
|
@alias module:Jqgrid_utils
|
|
175
|
+
@param {object} - row object
|
|
176
|
+
@param {string} - url of the API
|
|
177
|
+
@param {string} - data oject
|
|
178
|
+
@returns {object} {update: 'ok'} or {udpate: 'failed'}
|
|
179
|
+
@example
|
|
180
|
+
var jqu = new Jqgrid_utils();
|
|
181
|
+
afterSetRow: async function(row)
|
|
182
|
+
{
|
|
183
|
+
let r = await jqu.upsert_row(row, url);
|
|
184
|
+
console.log(r);
|
|
185
|
+
},
|
|
159
186
|
*/
|
|
160
187
|
async upsert_row(row, url, req = {})
|
|
161
188
|
{
|
|
@@ -171,8 +198,21 @@ async upsert_row(row, url, req = {})
|
|
|
171
198
|
}
|
|
172
199
|
}
|
|
173
200
|
|
|
201
|
+
|
|
174
202
|
/**
|
|
203
|
+
* Insert from the grid to an API used by the upsert_row function
|
|
175
204
|
@alias module:Jqgrid_utils
|
|
205
|
+
@param {object} - row object
|
|
206
|
+
@param {string} - url of the API
|
|
207
|
+
@param {string} - data oject
|
|
208
|
+
@returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
209
|
+
@example
|
|
210
|
+
var jqu = new Jqgrid_utils();
|
|
211
|
+
afterSetRow: async function(row)
|
|
212
|
+
{
|
|
213
|
+
let r = await jqu.upsert_row(row, url);
|
|
214
|
+
console.log(r);
|
|
215
|
+
},
|
|
176
216
|
*/
|
|
177
217
|
async insert_row(row, url)
|
|
178
218
|
{
|
|
@@ -196,8 +236,21 @@ async insert_row(row, url)
|
|
|
196
236
|
|
|
197
237
|
|
|
198
238
|
/**
|
|
239
|
+
* Update from the grid to an API used by the upsert_row function
|
|
199
240
|
@alias module:Jqgrid_utils
|
|
241
|
+
@param {object} - row object
|
|
242
|
+
@param {string} - url of the API
|
|
243
|
+
@param {string} - data oject
|
|
244
|
+
@returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
245
|
+
@example
|
|
246
|
+
var jqu = new Jqgrid_utils();
|
|
247
|
+
afterSetRow: async function(row)
|
|
248
|
+
{
|
|
249
|
+
let r = await jqu.upsert_row(row, url);
|
|
250
|
+
console.log(r);
|
|
251
|
+
},
|
|
200
252
|
*/
|
|
253
|
+
|
|
201
254
|
async update_row(row, url, req = {})
|
|
202
255
|
{
|
|
203
256
|
let ret = '';
|
|
@@ -219,8 +272,20 @@ async update_row(row, url, req = {})
|
|
|
219
272
|
}
|
|
220
273
|
|
|
221
274
|
/**
|
|
275
|
+
* Delete from the grid to an API
|
|
222
276
|
@alias module:Jqgrid_utils
|
|
277
|
+
@param {string} - row id
|
|
278
|
+
@param {string} - url of the API
|
|
279
|
+
@returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
280
|
+
@example
|
|
281
|
+
var jqu = new Jqgrid_utils();
|
|
282
|
+
afterDelRow: async function(row)
|
|
283
|
+
{
|
|
284
|
+
const r = await jqu.delete_row(row, url);
|
|
285
|
+
console.log(r + ' : ' + row + ' - from API');
|
|
286
|
+
},
|
|
223
287
|
*/
|
|
288
|
+
|
|
224
289
|
async delete_row(_id, url)
|
|
225
290
|
{
|
|
226
291
|
let ret = '';
|
|
@@ -239,8 +304,18 @@ async delete_row(_id, url)
|
|
|
239
304
|
|
|
240
305
|
|
|
241
306
|
/**
|
|
307
|
+
* Async Delete request used by function delete_row
|
|
242
308
|
@alias module:Jqgrid_utils
|
|
309
|
+
@param {string} - url of the API
|
|
310
|
+
@returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
311
|
+
@example
|
|
312
|
+
var jqu = new Jqgrid_utils();
|
|
313
|
+
afterDelRow: async function(row)
|
|
314
|
+
{
|
|
315
|
+
ret = JSON.parse(await jqu.adelete_api(url));
|
|
316
|
+
},
|
|
243
317
|
*/
|
|
318
|
+
|
|
244
319
|
async adelete_api(url, json = false)
|
|
245
320
|
{
|
|
246
321
|
const ctype = json ? "application/json;charset=UTF-8" : "application/x-www-form-urlencoded";
|
|
@@ -256,9 +331,18 @@ async adelete_api(url, json = false)
|
|
|
256
331
|
}
|
|
257
332
|
|
|
258
333
|
|
|
334
|
+
|
|
259
335
|
/**
|
|
336
|
+
* Async Post request used by the update_row function
|
|
260
337
|
@alias module:Jqgrid_utils
|
|
338
|
+
@param {string} - url of the API
|
|
339
|
+
@param {object} - json object
|
|
340
|
+
@returns {object} @returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
341
|
+
@example
|
|
342
|
+
var jqu = new Jqgrid_utils();
|
|
343
|
+
ret = JSON.parse(await jqu.post_json(url,{'key':value,'key2':'value'}));
|
|
261
344
|
*/
|
|
345
|
+
|
|
262
346
|
async post_json(url, data)
|
|
263
347
|
{
|
|
264
348
|
return new Promise((resolve, reject) =>
|
|
@@ -273,7 +357,14 @@ async post_json(url, data)
|
|
|
273
357
|
}
|
|
274
358
|
|
|
275
359
|
/**
|
|
360
|
+
* Async Put request used by the insert_row function
|
|
276
361
|
@alias module:Jqgrid_utils
|
|
362
|
+
@param {string} - url of the API
|
|
363
|
+
@param {object} - json object
|
|
364
|
+
@returns {object} @returns {object} Object from the the API like {insert: 'ok'} or {insert: 'failed'}
|
|
365
|
+
@example
|
|
366
|
+
var jqu = new Jqgrid_utils();
|
|
367
|
+
ret = JSON.parse(await jqu.put_json(url,{'key':value,'key2':'value2'}));
|
|
277
368
|
*/
|
|
278
369
|
async put_json(url, data)
|
|
279
370
|
{
|
|
@@ -288,14 +379,24 @@ async put_json(url, data)
|
|
|
288
379
|
});
|
|
289
380
|
}
|
|
290
381
|
|
|
291
|
-
|
|
382
|
+
/**
|
|
383
|
+
* Hide the del iconf rom the grid
|
|
384
|
+
@alias module:Jqgrid_utils
|
|
385
|
+
@example
|
|
386
|
+
var jqu = new Jqgrid_utils();
|
|
387
|
+
jqu.hide_del_icon();
|
|
388
|
+
*/
|
|
292
389
|
s_hide_del_icon()
|
|
293
390
|
{
|
|
294
391
|
hide_del_icon();
|
|
295
392
|
}
|
|
296
393
|
|
|
297
394
|
/**
|
|
395
|
+
* Hide the del iconf rom the grid
|
|
298
396
|
@alias module:Jqgrid_utils
|
|
397
|
+
@example
|
|
398
|
+
var jqu = new Jqgrid_utils();
|
|
399
|
+
await jqu.hide_del_icon();
|
|
299
400
|
*/
|
|
300
401
|
async hide_del_icon()
|
|
301
402
|
{
|
|
@@ -305,9 +406,16 @@ async hide_del_icon()
|
|
|
305
406
|
|
|
306
407
|
|
|
307
408
|
/**
|
|
409
|
+
* Convert a cell into a link/url with data from another cell
|
|
308
410
|
@alias module:Jqgrid_utils
|
|
411
|
+
@param {object} - col_model of the grid
|
|
412
|
+
@param {string} - URL string
|
|
413
|
+
@param {string} - Column/Cell to use
|
|
414
|
+
@param {string} - URL Attributes
|
|
415
|
+
@param {object} - keys and fields value to use
|
|
309
416
|
@example
|
|
310
|
-
|
|
417
|
+
var jqu = new Jqgrid_utils();
|
|
418
|
+
col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
|
|
311
419
|
*/
|
|
312
420
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
313
421
|
{
|
|
@@ -377,9 +485,16 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
377
485
|
|
|
378
486
|
|
|
379
487
|
/**
|
|
488
|
+
* Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
|
|
380
489
|
@alias module:Jqgrid_utils
|
|
490
|
+
@param {object} - col_model of the grid
|
|
491
|
+
@param {string} - URL string
|
|
492
|
+
@param {string} - Column/Cell to use
|
|
493
|
+
@param {string} - URL Attributes
|
|
494
|
+
@param {object} - keys and fields value to use
|
|
381
495
|
@example
|
|
382
|
-
|
|
496
|
+
var jqu = new Jqgrid_utils();
|
|
497
|
+
col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
|
|
383
498
|
*/
|
|
384
499
|
async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
|
|
385
500
|
{
|
|
@@ -444,6 +559,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
444
559
|
|
|
445
560
|
|
|
446
561
|
/**
|
|
562
|
+
* Private Function
|
|
447
563
|
@alias module:Jqgrid_utils
|
|
448
564
|
*/
|
|
449
565
|
__cell_format(cell_value, format)
|
package/jqgrid_utils.js
CHANGED
|
@@ -32,10 +32,10 @@ module.exports = class Vanilla_website_utils
|
|
|
32
32
|
@param {object} - col_model of the grid
|
|
33
33
|
@param {string} - name of the column what should get convert to the url
|
|
34
34
|
@param {string} - the used url of the data
|
|
35
|
+
@returns {string} https://foo.bar.com/av0_code/bar
|
|
35
36
|
@example
|
|
37
|
+
var jqu = new Jqgrid_utils();
|
|
36
38
|
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
|
|
37
|
-
@result
|
|
38
|
-
* https://foo.bar.com/av0_code/bar
|
|
39
39
|
*/
|
|
40
40
|
async set_link(col_model, edit_field, url ,attr='')
|
|
41
41
|
{
|
|
@@ -52,6 +52,16 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
|
|
|
52
52
|
return col_model;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
@alias module:Jqgrid_utils
|
|
57
|
+
@param {object} - gridobject;
|
|
58
|
+
@param {object} - grid data (optional);
|
|
59
|
+
@example
|
|
60
|
+
var jqu = new Jqgrid_utils();
|
|
61
|
+
loadComplete: function(){
|
|
62
|
+
jqu.grid_set_caption(this);
|
|
63
|
+
},
|
|
64
|
+
*/
|
|
55
65
|
|
|
56
66
|
s_grid_set_caption(_grid, data=[])
|
|
57
67
|
{
|
|
@@ -65,7 +75,7 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
|
|
|
65
75
|
@example
|
|
66
76
|
var jqu = new Jqgrid_utils();
|
|
67
77
|
loadComplete: function(){
|
|
68
|
-
jqu.grid_set_caption(this);
|
|
78
|
+
await jqu.grid_set_caption(this);
|
|
69
79
|
},
|
|
70
80
|
*/
|
|
71
81
|
async grid_set_caption(_grid, data=[])
|
|
@@ -88,6 +98,11 @@ loadComplete: function(){
|
|
|
88
98
|
|
|
89
99
|
/**
|
|
90
100
|
@alias module:Jqgrid_utils
|
|
101
|
+
@param {object} - the col_model of the grid
|
|
102
|
+
@param {string} - the name of the page(optional)
|
|
103
|
+
@param {object} - the grid objec(optional)
|
|
104
|
+
@example
|
|
105
|
+
col_model = await jqu.resize_saved_cell_width(col_model);
|
|
91
106
|
*/
|
|
92
107
|
s_resize_saved_cell_width(col_model, page=false, grid=false)
|
|
93
108
|
{
|
|
@@ -154,7 +169,19 @@ col_model = await jqu.resize_saved_cell_width(col_model);
|
|
|
154
169
|
|
|
155
170
|
|
|
156
171
|
/**
|
|
172
|
+
* Upsert(insert or update) from the grid to an API
|
|
157
173
|
@alias module:Jqgrid_utils
|
|
174
|
+
@param {object} - row object
|
|
175
|
+
@param {string} - url of the API
|
|
176
|
+
@param {string} - data oject
|
|
177
|
+
@returns {object} {update: 'ok'} or {udpate: 'failed'}
|
|
178
|
+
@example
|
|
179
|
+
var jqu = new Jqgrid_utils();
|
|
180
|
+
afterSetRow: async function(row)
|
|
181
|
+
{
|
|
182
|
+
let r = await jqu.upsert_row(row, url);
|
|
183
|
+
console.log(r);
|
|
184
|
+
},
|
|
158
185
|
*/
|
|
159
186
|
async upsert_row(row, url, req = {})
|
|
160
187
|
{
|
|
@@ -170,8 +197,21 @@ async upsert_row(row, url, req = {})
|
|
|
170
197
|
}
|
|
171
198
|
}
|
|
172
199
|
|
|
200
|
+
|
|
173
201
|
/**
|
|
202
|
+
* Insert from the grid to an API used by the upsert_row function
|
|
174
203
|
@alias module:Jqgrid_utils
|
|
204
|
+
@param {object} - row object
|
|
205
|
+
@param {string} - url of the API
|
|
206
|
+
@param {string} - data oject
|
|
207
|
+
@returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
208
|
+
@example
|
|
209
|
+
var jqu = new Jqgrid_utils();
|
|
210
|
+
afterSetRow: async function(row)
|
|
211
|
+
{
|
|
212
|
+
let r = await jqu.upsert_row(row, url);
|
|
213
|
+
console.log(r);
|
|
214
|
+
},
|
|
175
215
|
*/
|
|
176
216
|
async insert_row(row, url)
|
|
177
217
|
{
|
|
@@ -195,8 +235,21 @@ async insert_row(row, url)
|
|
|
195
235
|
|
|
196
236
|
|
|
197
237
|
/**
|
|
238
|
+
* Update from the grid to an API used by the upsert_row function
|
|
198
239
|
@alias module:Jqgrid_utils
|
|
240
|
+
@param {object} - row object
|
|
241
|
+
@param {string} - url of the API
|
|
242
|
+
@param {string} - data oject
|
|
243
|
+
@returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
244
|
+
@example
|
|
245
|
+
var jqu = new Jqgrid_utils();
|
|
246
|
+
afterSetRow: async function(row)
|
|
247
|
+
{
|
|
248
|
+
let r = await jqu.upsert_row(row, url);
|
|
249
|
+
console.log(r);
|
|
250
|
+
},
|
|
199
251
|
*/
|
|
252
|
+
|
|
200
253
|
async update_row(row, url, req = {})
|
|
201
254
|
{
|
|
202
255
|
let ret = '';
|
|
@@ -218,8 +271,20 @@ async update_row(row, url, req = {})
|
|
|
218
271
|
}
|
|
219
272
|
|
|
220
273
|
/**
|
|
274
|
+
* Delete from the grid to an API
|
|
221
275
|
@alias module:Jqgrid_utils
|
|
276
|
+
@param {string} - row id
|
|
277
|
+
@param {string} - url of the API
|
|
278
|
+
@returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
279
|
+
@example
|
|
280
|
+
var jqu = new Jqgrid_utils();
|
|
281
|
+
afterDelRow: async function(row)
|
|
282
|
+
{
|
|
283
|
+
const r = await jqu.delete_row(row, url);
|
|
284
|
+
console.log(r + ' : ' + row + ' - from API');
|
|
285
|
+
},
|
|
222
286
|
*/
|
|
287
|
+
|
|
223
288
|
async delete_row(_id, url)
|
|
224
289
|
{
|
|
225
290
|
let ret = '';
|
|
@@ -238,8 +303,18 @@ async delete_row(_id, url)
|
|
|
238
303
|
|
|
239
304
|
|
|
240
305
|
/**
|
|
306
|
+
* Async Delete request used by function delete_row
|
|
241
307
|
@alias module:Jqgrid_utils
|
|
308
|
+
@param {string} - url of the API
|
|
309
|
+
@returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
310
|
+
@example
|
|
311
|
+
var jqu = new Jqgrid_utils();
|
|
312
|
+
afterDelRow: async function(row)
|
|
313
|
+
{
|
|
314
|
+
ret = JSON.parse(await jqu.adelete_api(url));
|
|
315
|
+
},
|
|
242
316
|
*/
|
|
317
|
+
|
|
243
318
|
async adelete_api(url, json = false)
|
|
244
319
|
{
|
|
245
320
|
const ctype = json ? "application/json;charset=UTF-8" : "application/x-www-form-urlencoded";
|
|
@@ -255,9 +330,18 @@ async adelete_api(url, json = false)
|
|
|
255
330
|
}
|
|
256
331
|
|
|
257
332
|
|
|
333
|
+
|
|
258
334
|
/**
|
|
335
|
+
* Async Post request used by the update_row function
|
|
259
336
|
@alias module:Jqgrid_utils
|
|
337
|
+
@param {string} - url of the API
|
|
338
|
+
@param {object} - json object
|
|
339
|
+
@returns {object} @returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
340
|
+
@example
|
|
341
|
+
var jqu = new Jqgrid_utils();
|
|
342
|
+
ret = JSON.parse(await jqu.post_json(url,{'key':value,'key2':'value'}));
|
|
260
343
|
*/
|
|
344
|
+
|
|
261
345
|
async post_json(url, data)
|
|
262
346
|
{
|
|
263
347
|
return new Promise((resolve, reject) =>
|
|
@@ -272,7 +356,14 @@ async post_json(url, data)
|
|
|
272
356
|
}
|
|
273
357
|
|
|
274
358
|
/**
|
|
359
|
+
* Async Put request used by the insert_row function
|
|
275
360
|
@alias module:Jqgrid_utils
|
|
361
|
+
@param {string} - url of the API
|
|
362
|
+
@param {object} - json object
|
|
363
|
+
@returns {object} @returns {object} Object from the the API like {insert: 'ok'} or {insert: 'failed'}
|
|
364
|
+
@example
|
|
365
|
+
var jqu = new Jqgrid_utils();
|
|
366
|
+
ret = JSON.parse(await jqu.put_json(url,{'key':value,'key2':'value2'}));
|
|
276
367
|
*/
|
|
277
368
|
async put_json(url, data)
|
|
278
369
|
{
|
|
@@ -287,14 +378,24 @@ async put_json(url, data)
|
|
|
287
378
|
});
|
|
288
379
|
}
|
|
289
380
|
|
|
290
|
-
|
|
381
|
+
/**
|
|
382
|
+
* Hide the del iconf rom the grid
|
|
383
|
+
@alias module:Jqgrid_utils
|
|
384
|
+
@example
|
|
385
|
+
var jqu = new Jqgrid_utils();
|
|
386
|
+
jqu.hide_del_icon();
|
|
387
|
+
*/
|
|
291
388
|
s_hide_del_icon()
|
|
292
389
|
{
|
|
293
390
|
hide_del_icon();
|
|
294
391
|
}
|
|
295
392
|
|
|
296
393
|
/**
|
|
394
|
+
* Hide the del iconf rom the grid
|
|
297
395
|
@alias module:Jqgrid_utils
|
|
396
|
+
@example
|
|
397
|
+
var jqu = new Jqgrid_utils();
|
|
398
|
+
await jqu.hide_del_icon();
|
|
298
399
|
*/
|
|
299
400
|
async hide_del_icon()
|
|
300
401
|
{
|
|
@@ -304,9 +405,16 @@ async hide_del_icon()
|
|
|
304
405
|
|
|
305
406
|
|
|
306
407
|
/**
|
|
408
|
+
* Convert a cell into a link/url with data from another cell
|
|
307
409
|
@alias module:Jqgrid_utils
|
|
410
|
+
@param {object} - col_model of the grid
|
|
411
|
+
@param {string} - URL string
|
|
412
|
+
@param {string} - Column/Cell to use
|
|
413
|
+
@param {string} - URL Attributes
|
|
414
|
+
@param {object} - keys and fields value to use
|
|
308
415
|
@example
|
|
309
|
-
|
|
416
|
+
var jqu = new Jqgrid_utils();
|
|
417
|
+
col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
|
|
310
418
|
*/
|
|
311
419
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
312
420
|
{
|
|
@@ -376,9 +484,16 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
376
484
|
|
|
377
485
|
|
|
378
486
|
/**
|
|
487
|
+
* Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
|
|
379
488
|
@alias module:Jqgrid_utils
|
|
489
|
+
@param {object} - col_model of the grid
|
|
490
|
+
@param {string} - URL string
|
|
491
|
+
@param {string} - Column/Cell to use
|
|
492
|
+
@param {string} - URL Attributes
|
|
493
|
+
@param {object} - keys and fields value to use
|
|
380
494
|
@example
|
|
381
|
-
|
|
495
|
+
var jqu = new Jqgrid_utils();
|
|
496
|
+
col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
|
|
382
497
|
*/
|
|
383
498
|
async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
|
|
384
499
|
{
|
|
@@ -443,6 +558,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
443
558
|
|
|
444
559
|
|
|
445
560
|
/**
|
|
561
|
+
* Private Function
|
|
446
562
|
@alias module:Jqgrid_utils
|
|
447
563
|
*/
|
|
448
564
|
__cell_format(cell_value, format)
|
package/package.json
CHANGED