jqgrid_utils 1.2.16 → 1.2.19
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 +216 -22
- package/dist/jqgrid_utils.js +120 -4
- package/jqgrid_utils.js +121 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,20 +37,22 @@ A module for Jqgrid_utils
|
|
|
37
37
|
|
|
38
38
|
* [Jqgrid_utils](#module_Jqgrid_utils)
|
|
39
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, json)](#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) ⏏
|
|
@@ -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 {update: '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, 'http://api.com',{'key':'value'});
|
|
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
|
+
|
|
197
|
+
**Example**
|
|
198
|
+
```js
|
|
199
|
+
var jqu = new Jqgrid_utils();
|
|
200
|
+
afterSetRow: async function(row)
|
|
201
|
+
{
|
|
202
|
+
let r = await jqu.insert_row(row, 'http://api.com');
|
|
203
|
+
console.log(r);
|
|
204
|
+
},
|
|
205
|
+
```
|
|
138
206
|
<a name="exp_module_Jqgrid_utils--module.exports+update_row"></a>
|
|
139
207
|
|
|
140
|
-
### module.exports#update\_row() ⏏
|
|
208
|
+
### module.exports#update\_row(row, url, req) ⇒ <code>object</code> ⏏
|
|
209
|
+
Update from the grid to an API used by the upsert_row function
|
|
210
|
+
|
|
141
211
|
**Kind**: Exported function
|
|
212
|
+
**Returns**: <code>object</code> - Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
213
|
+
|
|
214
|
+
| Param | Type | Description |
|
|
215
|
+
| --- | --- | --- |
|
|
216
|
+
| row | <code>object</code> | row object |
|
|
217
|
+
| url | <code>string</code> | url of the API |
|
|
218
|
+
| req | <code>string</code> | data oject |
|
|
219
|
+
|
|
220
|
+
**Example**
|
|
221
|
+
```js
|
|
222
|
+
var jqu = new Jqgrid_utils();
|
|
223
|
+
afterSetRow: async function(row)
|
|
224
|
+
{
|
|
225
|
+
let r = await jqu.update_row(row, 'http://api.com',{'key':value});
|
|
226
|
+
console.log(r);
|
|
227
|
+
},
|
|
228
|
+
```
|
|
142
229
|
<a name="exp_module_Jqgrid_utils--module.exports+delete_row"></a>
|
|
143
230
|
|
|
144
|
-
### module.exports#delete\_row() ⏏
|
|
231
|
+
### module.exports#delete\_row(_id, url) ⇒ <code>object</code> ⏏
|
|
232
|
+
Delete from the grid to an API
|
|
233
|
+
|
|
145
234
|
**Kind**: Exported function
|
|
235
|
+
**Returns**: <code>object</code> - @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
236
|
+
|
|
237
|
+
| Param | Type | Description |
|
|
238
|
+
| --- | --- | --- |
|
|
239
|
+
| _id | <code>string</code> | row id |
|
|
240
|
+
| url | <code>string</code> | url of the API |
|
|
241
|
+
|
|
242
|
+
**Example**
|
|
243
|
+
```js
|
|
244
|
+
var jqu = new Jqgrid_utils();
|
|
245
|
+
afterDelRow: async function(row)
|
|
246
|
+
{
|
|
247
|
+
const r = await jqu.delete_row('id', 'http://api.com');
|
|
248
|
+
console.log(r + ' : ' + row + ' - from API');
|
|
249
|
+
},
|
|
250
|
+
```
|
|
146
251
|
<a name="exp_module_Jqgrid_utils--module.exports+adelete_api"></a>
|
|
147
252
|
|
|
148
|
-
### module.exports#adelete\_api() ⏏
|
|
253
|
+
### module.exports#adelete\_api(url, json) ⇒ <code>object</code> ⏏
|
|
254
|
+
Async Delete request used by function delete_row
|
|
255
|
+
|
|
149
256
|
**Kind**: Exported function
|
|
257
|
+
**Returns**: <code>object</code> - @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
258
|
+
|
|
259
|
+
| Param | Type | Default | Description |
|
|
260
|
+
| --- | --- | --- | --- |
|
|
261
|
+
| url | <code>string</code> | | url of the API |
|
|
262
|
+
| json | <code>boalan</code> | <code>false</code> | header should be json type? default form type |
|
|
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
|
@@ -35,6 +35,7 @@ module.exports = class Vanilla_website_utils
|
|
|
35
35
|
@param {string} - the used url of the data
|
|
36
36
|
@returns {string} https://foo.bar.com/av0_code/bar
|
|
37
37
|
@example
|
|
38
|
+
var jqu = new Jqgrid_utils();
|
|
38
39
|
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
|
|
39
40
|
*/
|
|
40
41
|
async set_link(col_model, edit_field, url ,attr='')
|
|
@@ -52,6 +53,16 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
|
|
|
52
53
|
return col_model;
|
|
53
54
|
}
|
|
54
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
|
+
*/
|
|
55
66
|
|
|
56
67
|
s_grid_set_caption(_grid, data=[])
|
|
57
68
|
{
|
|
@@ -65,7 +76,7 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
|
|
|
65
76
|
@example
|
|
66
77
|
var jqu = new Jqgrid_utils();
|
|
67
78
|
loadComplete: function(){
|
|
68
|
-
jqu.grid_set_caption(this);
|
|
79
|
+
await jqu.grid_set_caption(this);
|
|
69
80
|
},
|
|
70
81
|
*/
|
|
71
82
|
async grid_set_caption(_grid, data=[])
|
|
@@ -88,6 +99,11 @@ loadComplete: function(){
|
|
|
88
99
|
|
|
89
100
|
/**
|
|
90
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);
|
|
91
107
|
*/
|
|
92
108
|
s_resize_saved_cell_width(col_model, page=false, grid=false)
|
|
93
109
|
{
|
|
@@ -154,7 +170,19 @@ col_model = await jqu.resize_saved_cell_width(col_model);
|
|
|
154
170
|
|
|
155
171
|
|
|
156
172
|
/**
|
|
173
|
+
* Upsert(insert or update) from the grid to an API
|
|
157
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
|
+
},
|
|
158
186
|
*/
|
|
159
187
|
async upsert_row(row, url, req = {})
|
|
160
188
|
{
|
|
@@ -170,8 +198,20 @@ async upsert_row(row, url, req = {})
|
|
|
170
198
|
}
|
|
171
199
|
}
|
|
172
200
|
|
|
201
|
+
|
|
173
202
|
/**
|
|
203
|
+
* Insert from the grid to an API used by the upsert_row function
|
|
174
204
|
@alias module:Jqgrid_utils
|
|
205
|
+
@param {object} - row object
|
|
206
|
+
@param {string} - URL of the API
|
|
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/jqgrid_utils.js
CHANGED
|
@@ -34,6 +34,7 @@ module.exports = class Vanilla_website_utils
|
|
|
34
34
|
@param {string} - the used url of the data
|
|
35
35
|
@returns {string} https://foo.bar.com/av0_code/bar
|
|
36
36
|
@example
|
|
37
|
+
var jqu = new Jqgrid_utils();
|
|
37
38
|
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
|
|
38
39
|
*/
|
|
39
40
|
async set_link(col_model, edit_field, url ,attr='')
|
|
@@ -51,6 +52,16 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
|
|
|
51
52
|
return col_model;
|
|
52
53
|
}
|
|
53
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
|
+
*/
|
|
54
65
|
|
|
55
66
|
s_grid_set_caption(_grid, data=[])
|
|
56
67
|
{
|
|
@@ -64,7 +75,7 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
|
|
|
64
75
|
@example
|
|
65
76
|
var jqu = new Jqgrid_utils();
|
|
66
77
|
loadComplete: function(){
|
|
67
|
-
jqu.grid_set_caption(this);
|
|
78
|
+
await jqu.grid_set_caption(this);
|
|
68
79
|
},
|
|
69
80
|
*/
|
|
70
81
|
async grid_set_caption(_grid, data=[])
|
|
@@ -87,6 +98,11 @@ loadComplete: function(){
|
|
|
87
98
|
|
|
88
99
|
/**
|
|
89
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);
|
|
90
106
|
*/
|
|
91
107
|
s_resize_saved_cell_width(col_model, page=false, grid=false)
|
|
92
108
|
{
|
|
@@ -153,7 +169,19 @@ col_model = await jqu.resize_saved_cell_width(col_model);
|
|
|
153
169
|
|
|
154
170
|
|
|
155
171
|
/**
|
|
172
|
+
* Upsert(insert or update) from the grid to an API
|
|
156
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 {update: 'failed'}
|
|
178
|
+
@example
|
|
179
|
+
var jqu = new Jqgrid_utils();
|
|
180
|
+
afterSetRow: async function(row)
|
|
181
|
+
{
|
|
182
|
+
let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
|
|
183
|
+
console.log(r);
|
|
184
|
+
},
|
|
157
185
|
*/
|
|
158
186
|
async upsert_row(row, url, req = {})
|
|
159
187
|
{
|
|
@@ -169,8 +197,20 @@ async upsert_row(row, url, req = {})
|
|
|
169
197
|
}
|
|
170
198
|
}
|
|
171
199
|
|
|
200
|
+
|
|
172
201
|
/**
|
|
202
|
+
* Insert from the grid to an API used by the upsert_row function
|
|
173
203
|
@alias module:Jqgrid_utils
|
|
204
|
+
@param {object} - row object
|
|
205
|
+
@param {string} - URL of the API
|
|
206
|
+
@returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
207
|
+
@example
|
|
208
|
+
var jqu = new Jqgrid_utils();
|
|
209
|
+
afterSetRow: async function(row)
|
|
210
|
+
{
|
|
211
|
+
let r = await jqu.insert_row(row, 'http://api.com');
|
|
212
|
+
console.log(r);
|
|
213
|
+
},
|
|
174
214
|
*/
|
|
175
215
|
async insert_row(row, url)
|
|
176
216
|
{
|
|
@@ -194,8 +234,21 @@ async insert_row(row, url)
|
|
|
194
234
|
|
|
195
235
|
|
|
196
236
|
/**
|
|
237
|
+
* Update from the grid to an API used by the upsert_row function
|
|
197
238
|
@alias module:Jqgrid_utils
|
|
239
|
+
@param {object} - row object
|
|
240
|
+
@param {string} - url of the API
|
|
241
|
+
@param {string} - data oject
|
|
242
|
+
@returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
|
|
243
|
+
@example
|
|
244
|
+
var jqu = new Jqgrid_utils();
|
|
245
|
+
afterSetRow: async function(row)
|
|
246
|
+
{
|
|
247
|
+
let r = await jqu.update_row(row, 'http://api.com',{'key':value});
|
|
248
|
+
console.log(r);
|
|
249
|
+
},
|
|
198
250
|
*/
|
|
251
|
+
|
|
199
252
|
async update_row(row, url, req = {})
|
|
200
253
|
{
|
|
201
254
|
let ret = '';
|
|
@@ -217,8 +270,20 @@ async update_row(row, url, req = {})
|
|
|
217
270
|
}
|
|
218
271
|
|
|
219
272
|
/**
|
|
273
|
+
* Delete from the grid to an API
|
|
220
274
|
@alias module:Jqgrid_utils
|
|
275
|
+
@param {string} - row id
|
|
276
|
+
@param {string} - url of the API
|
|
277
|
+
@returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
278
|
+
@example
|
|
279
|
+
var jqu = new Jqgrid_utils();
|
|
280
|
+
afterDelRow: async function(row)
|
|
281
|
+
{
|
|
282
|
+
const r = await jqu.delete_row('id', 'http://api.com');
|
|
283
|
+
console.log(r + ' : ' + row + ' - from API');
|
|
284
|
+
},
|
|
221
285
|
*/
|
|
286
|
+
|
|
222
287
|
async delete_row(_id, url)
|
|
223
288
|
{
|
|
224
289
|
let ret = '';
|
|
@@ -237,8 +302,19 @@ async delete_row(_id, url)
|
|
|
237
302
|
|
|
238
303
|
|
|
239
304
|
/**
|
|
305
|
+
* Async Delete request used by function delete_row
|
|
240
306
|
@alias module:Jqgrid_utils
|
|
307
|
+
@param {string} - url of the API
|
|
308
|
+
@param {boalan} - header should be json type? default form type
|
|
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
|
+
},
|
|
241
316
|
*/
|
|
317
|
+
|
|
242
318
|
async adelete_api(url, json = false)
|
|
243
319
|
{
|
|
244
320
|
const ctype = json ? "application/json;charset=UTF-8" : "application/x-www-form-urlencoded";
|
|
@@ -254,9 +330,18 @@ async adelete_api(url, json = false)
|
|
|
254
330
|
}
|
|
255
331
|
|
|
256
332
|
|
|
333
|
+
|
|
257
334
|
/**
|
|
335
|
+
* Async Post request used by the update_row function
|
|
258
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'}));
|
|
259
343
|
*/
|
|
344
|
+
|
|
260
345
|
async post_json(url, data)
|
|
261
346
|
{
|
|
262
347
|
return new Promise((resolve, reject) =>
|
|
@@ -271,7 +356,14 @@ async post_json(url, data)
|
|
|
271
356
|
}
|
|
272
357
|
|
|
273
358
|
/**
|
|
359
|
+
* Async Put request used by the insert_row function
|
|
274
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'}));
|
|
275
367
|
*/
|
|
276
368
|
async put_json(url, data)
|
|
277
369
|
{
|
|
@@ -286,14 +378,24 @@ async put_json(url, data)
|
|
|
286
378
|
});
|
|
287
379
|
}
|
|
288
380
|
|
|
289
|
-
|
|
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
|
+
*/
|
|
290
388
|
s_hide_del_icon()
|
|
291
389
|
{
|
|
292
390
|
hide_del_icon();
|
|
293
391
|
}
|
|
294
392
|
|
|
295
393
|
/**
|
|
394
|
+
* Hide the del iconf rom the grid
|
|
296
395
|
@alias module:Jqgrid_utils
|
|
396
|
+
@example
|
|
397
|
+
var jqu = new Jqgrid_utils();
|
|
398
|
+
await jqu.hide_del_icon();
|
|
297
399
|
*/
|
|
298
400
|
async hide_del_icon()
|
|
299
401
|
{
|
|
@@ -303,9 +405,16 @@ async hide_del_icon()
|
|
|
303
405
|
|
|
304
406
|
|
|
305
407
|
/**
|
|
408
|
+
* Convert a cell into a link/url with data from another cell
|
|
306
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
|
|
307
415
|
@example
|
|
308
|
-
|
|
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"});
|
|
309
418
|
*/
|
|
310
419
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
311
420
|
{
|
|
@@ -375,9 +484,16 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
375
484
|
|
|
376
485
|
|
|
377
486
|
/**
|
|
487
|
+
* Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
|
|
378
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
|
|
379
494
|
@example
|
|
380
|
-
|
|
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"});
|
|
381
497
|
*/
|
|
382
498
|
async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
|
|
383
499
|
{
|
|
@@ -442,6 +558,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
442
558
|
|
|
443
559
|
|
|
444
560
|
/**
|
|
561
|
+
* Private Function
|
|
445
562
|
@alias module:Jqgrid_utils
|
|
446
563
|
*/
|
|
447
564
|
__cell_format(cell_value, format)
|
package/package.json
CHANGED