jqgrid_utils 1.2.19 → 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 +29 -2
- package/dist/jqgrid_utils.js +80 -9
- package/jqgrid_utils.js +74 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ A module for Jqgrid_utils
|
|
|
53
53
|
* [module.exports#hide_del_icon()](#exp_module_Jqgrid_utils--module.exports+hide_del_icon) ⏏
|
|
54
54
|
* [module.exports#add_link_details(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details) ⏏
|
|
55
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) ⏏
|
|
56
57
|
* [module.exports#__cell_format()](#exp_module_Jqgrid_utils--module.exports+__cell_format) ⏏
|
|
57
58
|
* [module.exports#subgrid(_id, id, data_url, col_model, caption)](#exp_module_Jqgrid_utils--module.exports+subgrid) ⏏
|
|
58
59
|
* [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Jqgrid_utils--module.exports+add_image) ⏏
|
|
@@ -345,7 +346,7 @@ Convert a cell into a link/url with data from another cell
|
|
|
345
346
|
**Example**
|
|
346
347
|
```js
|
|
347
348
|
var jqu = new Jqgrid_utils();
|
|
348
|
-
col_model = await jqu.add_link_details(col_model,'http://foo.bar'
|
|
349
|
+
col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
|
|
349
350
|
```
|
|
350
351
|
<a name="exp_module_Jqgrid_utils--module.exports+add_link_details_separator"></a>
|
|
351
352
|
|
|
@@ -365,7 +366,33 @@ Convert a cell into seperated based link/url like https://foo.bar.com/field/valu
|
|
|
365
366
|
**Example**
|
|
366
367
|
```js
|
|
367
368
|
var jqu = new Jqgrid_utils();
|
|
368
|
-
col_model = await jqu.add_link_details_separator(col_model,
|
|
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
|
+
|
|
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
|
+
|
|
386
|
+
**Example**
|
|
387
|
+
```js
|
|
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
|
+
]);
|
|
369
396
|
```
|
|
370
397
|
<a name="exp_module_Jqgrid_utils--module.exports+__cell_format"></a>
|
|
371
398
|
|
package/dist/jqgrid_utils.js
CHANGED
|
@@ -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 {
|
|
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,
|
|
183
|
+
let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
|
|
184
184
|
console.log(r);
|
|
185
185
|
},
|
|
186
186
|
*/
|
|
@@ -209,7 +209,7 @@ async upsert_row(row, url, req = {})
|
|
|
209
209
|
var jqu = new Jqgrid_utils();
|
|
210
210
|
afterSetRow: async function(row)
|
|
211
211
|
{
|
|
212
|
-
let r = await jqu.
|
|
212
|
+
let r = await jqu.insert_row(row, 'http://api.com');
|
|
213
213
|
console.log(r);
|
|
214
214
|
},
|
|
215
215
|
*/
|
|
@@ -245,7 +245,7 @@ async insert_row(row, url)
|
|
|
245
245
|
var jqu = new Jqgrid_utils();
|
|
246
246
|
afterSetRow: async function(row)
|
|
247
247
|
{
|
|
248
|
-
let r = await jqu.
|
|
248
|
+
let r = await jqu.update_row(row, 'http://api.com',{'key':value});
|
|
249
249
|
console.log(r);
|
|
250
250
|
},
|
|
251
251
|
*/
|
|
@@ -280,7 +280,7 @@ async update_row(row, url, req = {})
|
|
|
280
280
|
var jqu = new Jqgrid_utils();
|
|
281
281
|
afterDelRow: async function(row)
|
|
282
282
|
{
|
|
283
|
-
const r = await jqu.delete_row(
|
|
283
|
+
const r = await jqu.delete_row('id', 'http://api.com');
|
|
284
284
|
console.log(r + ' : ' + row + ' - from API');
|
|
285
285
|
},
|
|
286
286
|
*/
|
|
@@ -306,6 +306,7 @@ async delete_row(_id, url)
|
|
|
306
306
|
* Async Delete request used by function delete_row
|
|
307
307
|
@alias module:Jqgrid_utils
|
|
308
308
|
@param {string} - url of the API
|
|
309
|
+
@param {boalan} - header should be json type? default form type
|
|
309
310
|
@returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
310
311
|
@example
|
|
311
312
|
var jqu = new Jqgrid_utils();
|
|
@@ -414,7 +415,7 @@ async hide_del_icon()
|
|
|
414
415
|
@param {object} - keys and fields value to use
|
|
415
416
|
@example
|
|
416
417
|
var jqu = new Jqgrid_utils();
|
|
417
|
-
col_model = await jqu.add_link_details(col_model,'http://foo.bar'
|
|
418
|
+
col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
|
|
418
419
|
*/
|
|
419
420
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
420
421
|
{
|
|
@@ -493,7 +494,8 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
493
494
|
@param {object} - keys and fields value to use
|
|
494
495
|
@example
|
|
495
496
|
var jqu = new Jqgrid_utils();
|
|
496
|
-
col_model = await jqu.add_link_details_separator(col_model,
|
|
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"});
|
|
497
499
|
*/
|
|
498
500
|
async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
|
|
499
501
|
{
|
|
@@ -522,7 +524,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
522
524
|
{
|
|
523
525
|
if(key != '')
|
|
524
526
|
{
|
|
525
|
-
pref += key + '' + '/' + encodeURIComponent(key_val);
|
|
527
|
+
pref += key + '' + '/' + encodeURIComponent(key_val) + '/';
|
|
526
528
|
}
|
|
527
529
|
else
|
|
528
530
|
{
|
|
@@ -533,7 +535,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
533
535
|
}
|
|
534
536
|
if (pref)
|
|
535
537
|
{
|
|
536
|
-
if (pref.slice(-1) === '&')
|
|
538
|
+
if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
|
|
537
539
|
{
|
|
538
540
|
pref = pref.slice(0, -1);
|
|
539
541
|
}
|
|
@@ -554,8 +556,77 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
554
556
|
|
|
555
557
|
|
|
556
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
|
+
}
|
|
557
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
|
+
}
|
|
558
623
|
|
|
624
|
+
return cell_val;
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return col_model;
|
|
629
|
+
}
|
|
559
630
|
|
|
560
631
|
/**
|
|
561
632
|
* Private Function
|
package/jqgrid_utils.js
CHANGED
|
@@ -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'
|
|
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,
|
|
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