jqgrid_utils 1.2.17 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,20 +37,23 @@ 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) ⏏
56
+ * [module.exports#add_link_separator(col_model, url, edit_field, fields)](#exp_module_Jqgrid_utils--module.exports+add_link_separator) ⏏
54
57
  * [module.exports#__cell_format()](#exp_module_Jqgrid_utils--module.exports+__cell_format) ⏏
55
58
  * [module.exports#subgrid(_id, id, data_url, col_model, caption)](#exp_module_Jqgrid_utils--module.exports+subgrid) ⏏
56
59
  * [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Jqgrid_utils--module.exports+add_image) ⏏
@@ -73,8 +76,26 @@ Add an URL from the data to a specific cell/column
73
76
 
74
77
  **Example**
75
78
  ```js
79
+ var jqu = new Jqgrid_utils();
76
80
  col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
77
81
  ```
82
+ <a name="exp_module_Jqgrid_utils--module.exports+s_grid_set_caption"></a>
83
+
84
+ ### module.exports#s\_grid\_set\_caption(_grid, data) ⏏
85
+ **Kind**: Exported function
86
+
87
+ | Param | Type | Description |
88
+ | --- | --- | --- |
89
+ | _grid | <code>object</code> | gridobject; |
90
+ | data | <code>object</code> | grid data (optional); |
91
+
92
+ **Example**
93
+ ```js
94
+ var jqu = new Jqgrid_utils();
95
+ loadComplete: function(){
96
+ jqu.grid_set_caption(this);
97
+ },
98
+ ```
78
99
  <a name="exp_module_Jqgrid_utils--module.exports+grid_set_caption"></a>
79
100
 
80
101
  ### module.exports#grid\_set\_caption(_grid, data) ⏏
@@ -89,13 +110,24 @@ col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"')
89
110
  ```js
90
111
  var jqu = new Jqgrid_utils();
91
112
  loadComplete: function(){
92
- jqu.grid_set_caption(this);
113
+ await jqu.grid_set_caption(this);
93
114
  },
94
115
  ```
95
116
  <a name="exp_module_Jqgrid_utils--module.exports+s_resize_saved_cell_width"></a>
96
117
 
97
- ### module.exports#s\_resize\_saved\_cell\_width() ⏏
118
+ ### module.exports#s\_resize\_saved\_cell\_width(col_model, page, grid) ⏏
98
119
  **Kind**: Exported function
120
+
121
+ | Param | Type | Default | Description |
122
+ | --- | --- | --- | --- |
123
+ | col_model | <code>object</code> | | the col_model of the grid |
124
+ | page | <code>string</code> | <code>false</code> | the name of the page(optional) |
125
+ | grid | <code>object</code> | <code>false</code> | the grid objec(optional) |
126
+
127
+ **Example**
128
+ ```js
129
+ col_model = await jqu.resize_saved_cell_width(col_model);
130
+ ```
99
131
  <a name="exp_module_Jqgrid_utils--module.exports+resize_saved_cell_width"></a>
100
132
 
101
133
  ### module.exports#resize\_saved\_cell\_width(col_model, page, grid) ⏏
@@ -129,55 +161,244 @@ resizeStop: jqu.resize_cell,
129
161
  ```
130
162
  <a name="exp_module_Jqgrid_utils--module.exports+upsert_row"></a>
131
163
 
132
- ### module.exports#upsert\_row() ⏏
164
+ ### module.exports#upsert\_row(row, url, req) ⇒ <code>object</code>
165
+ Upsert(insert or update) from the grid to an API
166
+
133
167
  **Kind**: Exported function
168
+ **Returns**: <code>object</code> - {update: 'ok'} or {update: 'failed'}
169
+
170
+ | Param | Type | Description |
171
+ | --- | --- | --- |
172
+ | row | <code>object</code> | row object |
173
+ | url | <code>string</code> | url of the API |
174
+ | req | <code>string</code> | data oject |
175
+
176
+ **Example**
177
+ ```js
178
+ var jqu = new Jqgrid_utils();
179
+ afterSetRow: async function(row)
180
+ {
181
+ let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
182
+ console.log(r);
183
+ },
184
+ ```
134
185
  <a name="exp_module_Jqgrid_utils--module.exports+insert_row"></a>
135
186
 
136
- ### module.exports#insert\_row() ⏏
187
+ ### module.exports#insert\_row(row, url) ⇒ <code>object</code>
188
+ Insert from the grid to an API used by the upsert_row function
189
+
137
190
  **Kind**: Exported function
191
+ **Returns**: <code>object</code> - Object from the the API like {update: 'ok'} or {update: 'failed'}
192
+
193
+ | Param | Type | Description |
194
+ | --- | --- | --- |
195
+ | row | <code>object</code> | row object |
196
+ | url | <code>string</code> | URL of the API |
197
+
198
+ **Example**
199
+ ```js
200
+ var jqu = new Jqgrid_utils();
201
+ afterSetRow: async function(row)
202
+ {
203
+ let r = await jqu.insert_row(row, 'http://api.com');
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.update_row(row, 'http://api.com',{'key':value});
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('id', 'http://api.com');
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, json) ⇒ <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 | Default | Description |
261
+ | --- | --- | --- | --- |
262
+ | url | <code>string</code> | | url of the API |
263
+ | json | <code>boalan</code> | <code>false</code> | header should be json type? default form type |
264
+
265
+ **Example**
266
+ ```js
267
+ var jqu = new Jqgrid_utils();
268
+ afterDelRow: async function(row)
269
+ {
270
+ ret = JSON.parse(await jqu.adelete_api(url));
271
+ },
272
+ ```
150
273
  <a name="exp_module_Jqgrid_utils--module.exports+post_json"></a>
151
274
 
152
- ### module.exports#post\_json() ⏏
275
+ ### module.exports#post\_json(url, data) ⇒ <code>object</code>
276
+ Async Post request used by the update_row function
277
+
153
278
  **Kind**: Exported function
279
+ **Returns**: <code>object</code> - @returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
280
+
281
+ | Param | Type | Description |
282
+ | --- | --- | --- |
283
+ | url | <code>string</code> | url of the API |
284
+ | data | <code>object</code> | json object |
285
+
286
+ **Example**
287
+ ```js
288
+ var jqu = new Jqgrid_utils();
289
+ ret = JSON.parse(await jqu.post_json(url,{'key':value,'key2':'value'}));
290
+ ```
154
291
  <a name="exp_module_Jqgrid_utils--module.exports+put_json"></a>
155
292
 
156
- ### module.exports#put\_json() ⏏
293
+ ### module.exports#put\_json(url, data) ⇒ <code>object</code>
294
+ Async Put request used by the insert_row function
295
+
157
296
  **Kind**: Exported function
297
+ **Returns**: <code>object</code> - @returns {object} Object from the the API like {insert: 'ok'} or {insert: 'failed'}
298
+
299
+ | Param | Type | Description |
300
+ | --- | --- | --- |
301
+ | url | <code>string</code> | url of the API |
302
+ | data | <code>object</code> | json object |
303
+
304
+ **Example**
305
+ ```js
306
+ var jqu = new Jqgrid_utils();
307
+ ret = JSON.parse(await jqu.put_json(url,{'key':value,'key2':'value2'}));
308
+ ```
309
+ <a name="exp_module_Jqgrid_utils--module.exports+s_hide_del_icon"></a>
310
+
311
+ ### module.exports#s\_hide\_del\_icon() ⏏
312
+ Hide the del iconf rom the grid
313
+
314
+ **Kind**: Exported function
315
+ **Example**
316
+ ```js
317
+ var jqu = new Jqgrid_utils();
318
+ jqu.hide_del_icon();
319
+ ```
158
320
  <a name="exp_module_Jqgrid_utils--module.exports+hide_del_icon"></a>
159
321
 
160
322
  ### module.exports#hide\_del\_icon() ⏏
323
+ Hide the del iconf rom the grid
324
+
161
325
  **Kind**: Exported function
326
+ **Example**
327
+ ```js
328
+ var jqu = new Jqgrid_utils();
329
+ await jqu.hide_del_icon();
330
+ ```
162
331
  <a name="exp_module_Jqgrid_utils--module.exports+add_link_details"></a>
163
332
 
164
- ### module.exports#add\_link\_details() ⏏
333
+ ### module.exports#add\_link\_details(col_model, url, edit_field, attr, keys) ⏏
334
+ Convert a cell into a link/url with data from another cell
335
+
165
336
  **Kind**: Exported function
337
+
338
+ | Param | Type | Description |
339
+ | --- | --- | --- |
340
+ | col_model | <code>object</code> | col_model of the grid |
341
+ | url | <code>string</code> | URL string |
342
+ | edit_field | <code>string</code> | Column/Cell to use |
343
+ | attr | <code>string</code> | URL Attributes |
344
+ | keys | <code>object</code> | keys and fields value to use |
345
+
166
346
  **Example**
167
347
  ```js
168
- example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
348
+ var jqu = new Jqgrid_utils();
349
+ col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
169
350
  ```
170
351
  <a name="exp_module_Jqgrid_utils--module.exports+add_link_details_separator"></a>
171
352
 
172
- ### module.exports#add\_link\_details\_separator() ⏏
353
+ ### module.exports#add\_link\_details\_separator(col_model, url, edit_field, attr, keys) ⏏
354
+ Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
355
+
356
+ **Kind**: Exported function
357
+
358
+ | Param | Type | Description |
359
+ | --- | --- | --- |
360
+ | col_model | <code>object</code> | col_model of the grid |
361
+ | url | <code>string</code> | URL string |
362
+ | edit_field | <code>string</code> | Column/Cell to use |
363
+ | attr | <code>string</code> | URL Attributes |
364
+ | keys | <code>object</code> | keys and fields value to use |
365
+
366
+ **Example**
367
+ ```js
368
+ var jqu = new Jqgrid_utils();
369
+ col_model = await jqu.add_link_details_separator(col_model, url1 , 'style','target="_blank"',{"pricelist":"pricelist","style":"style"});
370
+ col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'target_column','target="_blank"',{"mykey":"myval"});
371
+ ```
372
+ <a name="exp_module_Jqgrid_utils--module.exports+add_link_separator"></a>
373
+
374
+ ### module.exports#add\_link\_separator(col_model, url, edit_field, fields) ⏏
375
+ Convert a cell into seperated based link/url include parameter based url like https://foo.bar.com/field.html?k=v
376
+
173
377
  **Kind**: Exported function
378
+
379
+ | Param | Type | Description |
380
+ | --- | --- | --- |
381
+ | col_model | <code>object</code> | col_model of the grid |
382
+ | url | <code>string</code> | URL string |
383
+ | edit_field | <code>array</code> | array of dict |
384
+ | fields | <code>string</code> | URL Attributes |
385
+
174
386
  **Example**
175
387
  ```js
176
- col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
388
+ var jqu = new Jqgrid_utils();
389
+ col_model = await jqu.add_link_separator(col_model, host + '/html' , 'style',[
390
+ {
391
+ 'field':'pricelist',
392
+ 'extension':'.html',
393
+ 'fields':{'style':'style'}
394
+ }
395
+ ]);
177
396
  ```
178
397
  <a name="exp_module_Jqgrid_utils--module.exports+__cell_format"></a>
179
398
 
180
399
  ### module.exports#\_\_cell\_format() ⏏
400
+ Private Function
401
+
181
402
  **Kind**: Exported function
182
403
  <a name="exp_module_Jqgrid_utils--module.exports+subgrid"></a>
183
404
 
@@ -175,12 +175,12 @@ col_model = await jqu.resize_saved_cell_width(col_model);
175
175
  @param {object} - row object
176
176
  @param {string} - url of the API
177
177
  @param {string} - data oject
178
- @returns {object} {update: 'ok'} or {udpate: 'failed'}
178
+ @returns {object} {update: 'ok'} or {update: 'failed'}
179
179
  @example
180
180
  var jqu = new Jqgrid_utils();
181
181
  afterSetRow: async function(row)
182
182
  {
183
- let r = await jqu.upsert_row(row, url);
183
+ let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
184
184
  console.log(r);
185
185
  },
186
186
  */
@@ -203,14 +203,13 @@ async upsert_row(row, url, req = {})
203
203
  * Insert from the grid to an API used by the upsert_row function
204
204
  @alias module:Jqgrid_utils
205
205
  @param {object} - row object
206
- @param {string} - url of the API
207
- @param {string} - data oject
206
+ @param {string} - URL of the API
208
207
  @returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
209
208
  @example
210
209
  var jqu = new Jqgrid_utils();
211
210
  afterSetRow: async function(row)
212
211
  {
213
- let r = await jqu.upsert_row(row, url);
212
+ let r = await jqu.insert_row(row, 'http://api.com');
214
213
  console.log(r);
215
214
  },
216
215
  */
@@ -246,7 +245,7 @@ async insert_row(row, url)
246
245
  var jqu = new Jqgrid_utils();
247
246
  afterSetRow: async function(row)
248
247
  {
249
- let r = await jqu.upsert_row(row, url);
248
+ let r = await jqu.update_row(row, 'http://api.com',{'key':value});
250
249
  console.log(r);
251
250
  },
252
251
  */
@@ -281,7 +280,7 @@ async update_row(row, url, req = {})
281
280
  var jqu = new Jqgrid_utils();
282
281
  afterDelRow: async function(row)
283
282
  {
284
- const r = await jqu.delete_row(row, url);
283
+ const r = await jqu.delete_row('id', 'http://api.com');
285
284
  console.log(r + ' : ' + row + ' - from API');
286
285
  },
287
286
  */
@@ -307,6 +306,7 @@ async delete_row(_id, url)
307
306
  * Async Delete request used by function delete_row
308
307
  @alias module:Jqgrid_utils
309
308
  @param {string} - url of the API
309
+ @param {boalan} - header should be json type? default form type
310
310
  @returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
311
311
  @example
312
312
  var jqu = new Jqgrid_utils();
@@ -415,7 +415,7 @@ async hide_del_icon()
415
415
  @param {object} - keys and fields value to use
416
416
  @example
417
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"});
418
+ col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
419
419
  */
420
420
  async add_link_details(col_model, url, edit_field, attr = '', keys, format)
421
421
  {
@@ -494,7 +494,8 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
494
494
  @param {object} - keys and fields value to use
495
495
  @example
496
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"});
497
+ col_model = await jqu.add_link_details_separator(col_model, url1 , 'style','target="_blank"',{"pricelist":"pricelist","style":"style"});
498
+ col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'target_column','target="_blank"',{"mykey":"myval"});
498
499
  */
499
500
  async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
500
501
  {
@@ -523,7 +524,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
523
524
  {
524
525
  if(key != '')
525
526
  {
526
- pref += key + '' + '/' + encodeURIComponent(key_val);
527
+ pref += key + '' + '/' + encodeURIComponent(key_val) + '/';
527
528
  }
528
529
  else
529
530
  {
@@ -534,7 +535,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
534
535
  }
535
536
  if (pref)
536
537
  {
537
- if (pref.slice(-1) === '&')
538
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
538
539
  {
539
540
  pref = pref.slice(0, -1);
540
541
  }
@@ -555,8 +556,77 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
555
556
 
556
557
 
557
558
 
559
+ /**
560
+ * Convert a cell into seperated based link/url include parameter based url like https://foo.bar.com/field.html?k=v
561
+ @alias module:Jqgrid_utils
562
+ @param {object} - col_model of the grid
563
+ @param {string} - URL string
564
+ @param {array} - array of dict
565
+ @param {string} - URL Attributes
566
+ @example
567
+ var jqu = new Jqgrid_utils();
568
+ col_model = await jqu.add_link_separator(col_model, host + '/html' , 'style',[
569
+ {
570
+ 'field':'pricelist',
571
+ 'extension':'.html',
572
+ 'fields':{'style':'style'}
573
+ }
574
+ ]);
575
+
576
+ */
577
+ async add_link_separator(col_model, url, edit_field, fields, attr='')
578
+ {
579
+ url = url + '/';
580
+ let self = this;
581
+ for (let i = 0; i < col_model.length; i++)
582
+ {
583
+ if (col_model[i]['name'] === edit_field)
584
+ {
585
+ col_model[i]['formatter'] = function(cell_val, obj)
586
+ {
587
+ let key_val = cell_val;
588
+ let pref = '';
589
+ for(let x in fields)
590
+ {
591
+ for(let xx in fields[x])
592
+ {
593
+ if(xx === 'field')
594
+ {
595
+ let field_value = obj.rowData[fields[x][xx]];
596
+ pref += field_value;
597
+ }
598
+ if(xx === 'extension')
599
+ {
600
+ pref += fields[x][xx] ;
601
+ }
602
+ if(xx === 'fields')
603
+ {
604
+ pref += '?';
605
+ for(let key in fields[x][xx])
606
+ {
607
+ let val = obj.rowData[fields[x][xx][key]];
608
+ pref = pref + '' + key + '=' + encodeURIComponent(val) + '&';
609
+ }
610
+ }
558
611
 
612
+ }
613
+ }
614
+ if (pref)
615
+ {
616
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
617
+ {
618
+ pref = pref.slice(0, -1);
619
+ }
620
+ const _cell_val = self.__cell_format(cell_val, format);
621
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
622
+ }
559
623
 
624
+ return cell_val;
625
+ };
626
+ }
627
+ }
628
+ return col_model;
629
+ }
560
630
 
561
631
  /**
562
632
  * Private Function
package/jqgrid_utils.js CHANGED
@@ -174,12 +174,12 @@ col_model = await jqu.resize_saved_cell_width(col_model);
174
174
  @param {object} - row object
175
175
  @param {string} - url of the API
176
176
  @param {string} - data oject
177
- @returns {object} {update: 'ok'} or {udpate: 'failed'}
177
+ @returns {object} {update: 'ok'} or {update: 'failed'}
178
178
  @example
179
179
  var jqu = new Jqgrid_utils();
180
180
  afterSetRow: async function(row)
181
181
  {
182
- let r = await jqu.upsert_row(row, url);
182
+ let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
183
183
  console.log(r);
184
184
  },
185
185
  */
@@ -202,14 +202,13 @@ async upsert_row(row, url, req = {})
202
202
  * Insert from the grid to an API used by the upsert_row function
203
203
  @alias module:Jqgrid_utils
204
204
  @param {object} - row object
205
- @param {string} - url of the API
206
- @param {string} - data oject
205
+ @param {string} - URL of the API
207
206
  @returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
208
207
  @example
209
208
  var jqu = new Jqgrid_utils();
210
209
  afterSetRow: async function(row)
211
210
  {
212
- let r = await jqu.upsert_row(row, url);
211
+ let r = await jqu.insert_row(row, 'http://api.com');
213
212
  console.log(r);
214
213
  },
215
214
  */
@@ -245,7 +244,7 @@ async insert_row(row, url)
245
244
  var jqu = new Jqgrid_utils();
246
245
  afterSetRow: async function(row)
247
246
  {
248
- let r = await jqu.upsert_row(row, url);
247
+ let r = await jqu.update_row(row, 'http://api.com',{'key':value});
249
248
  console.log(r);
250
249
  },
251
250
  */
@@ -280,7 +279,7 @@ async update_row(row, url, req = {})
280
279
  var jqu = new Jqgrid_utils();
281
280
  afterDelRow: async function(row)
282
281
  {
283
- const r = await jqu.delete_row(row, url);
282
+ const r = await jqu.delete_row('id', 'http://api.com');
284
283
  console.log(r + ' : ' + row + ' - from API');
285
284
  },
286
285
  */
@@ -306,6 +305,7 @@ async delete_row(_id, url)
306
305
  * Async Delete request used by function delete_row
307
306
  @alias module:Jqgrid_utils
308
307
  @param {string} - url of the API
308
+ @param {boalan} - header should be json type? default form type
309
309
  @returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
310
310
  @example
311
311
  var jqu = new Jqgrid_utils();
@@ -414,7 +414,7 @@ async hide_del_icon()
414
414
  @param {object} - keys and fields value to use
415
415
  @example
416
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"});
417
+ col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
418
418
  */
419
419
  async add_link_details(col_model, url, edit_field, attr = '', keys, format)
420
420
  {
@@ -493,7 +493,8 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
493
493
  @param {object} - keys and fields value to use
494
494
  @example
495
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"});
496
+ col_model = await jqu.add_link_details_separator(col_model, url1 , 'style','target="_blank"',{"pricelist":"pricelist","style":"style"});
497
+ col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'target_column','target="_blank"',{"mykey":"myval"});
497
498
  */
498
499
  async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
499
500
  {
@@ -522,7 +523,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
522
523
  {
523
524
  if(key != '')
524
525
  {
525
- pref += key + '' + '/' + encodeURIComponent(key_val);
526
+ pref += key + '' + '/' + encodeURIComponent(key_val) + '/';
526
527
  }
527
528
  else
528
529
  {
@@ -533,7 +534,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
533
534
  }
534
535
  if (pref)
535
536
  {
536
- if (pref.slice(-1) === '&')
537
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
537
538
  {
538
539
  pref = pref.slice(0, -1);
539
540
  }
@@ -554,8 +555,77 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
554
555
 
555
556
 
556
557
 
558
+ /**
559
+ * Convert a cell into seperated based link/url include parameter based url like https://foo.bar.com/field.html?k=v
560
+ @alias module:Jqgrid_utils
561
+ @param {object} - col_model of the grid
562
+ @param {string} - URL string
563
+ @param {array} - array of dict
564
+ @param {string} - URL Attributes
565
+ @example
566
+ var jqu = new Jqgrid_utils();
567
+ col_model = await jqu.add_link_separator(col_model, host + '/html' , 'style',[
568
+ {
569
+ 'field':'pricelist',
570
+ 'extension':'.html',
571
+ 'fields':{'style':'style'}
572
+ }
573
+ ]);
574
+
575
+ */
576
+ async add_link_separator(col_model, url, edit_field, fields, attr='')
577
+ {
578
+ url = url + '/';
579
+ let self = this;
580
+ for (let i = 0; i < col_model.length; i++)
581
+ {
582
+ if (col_model[i]['name'] === edit_field)
583
+ {
584
+ col_model[i]['formatter'] = function(cell_val, obj)
585
+ {
586
+ let key_val = cell_val;
587
+ let pref = '';
588
+ for(let x in fields)
589
+ {
590
+ for(let xx in fields[x])
591
+ {
592
+ if(xx === 'field')
593
+ {
594
+ let field_value = obj.rowData[fields[x][xx]];
595
+ pref += field_value;
596
+ }
597
+ if(xx === 'extension')
598
+ {
599
+ pref += fields[x][xx] ;
600
+ }
601
+ if(xx === 'fields')
602
+ {
603
+ pref += '?';
604
+ for(let key in fields[x][xx])
605
+ {
606
+ let val = obj.rowData[fields[x][xx][key]];
607
+ pref = pref + '' + key + '=' + encodeURIComponent(val) + '&';
608
+ }
609
+ }
557
610
 
611
+ }
612
+ }
613
+ if (pref)
614
+ {
615
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
616
+ {
617
+ pref = pref.slice(0, -1);
618
+ }
619
+ const _cell_val = self.__cell_format(cell_val, format);
620
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
621
+ }
558
622
 
623
+ return cell_val;
624
+ };
625
+ }
626
+ }
627
+ return col_model;
628
+ }
559
629
 
560
630
  /**
561
631
  * Private Function
package/package.json CHANGED
@@ -29,5 +29,5 @@
29
29
  {
30
30
  "test": "echo \"Error: no test specified\" && exit 1"
31
31
  },
32
- "version": "1.2.17"
32
+ "version": "1.3.0"
33
33
  }