jqgrid_utils 1.2.19 → 1.3.2
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 +31 -2
- package/dist/jqgrid_utils.js +81 -10
- package/jqgrid_utils.js +75 -5
- 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) ⏏
|
|
@@ -98,6 +99,8 @@ loadComplete: function(){
|
|
|
98
99
|
<a name="exp_module_Jqgrid_utils--module.exports+grid_set_caption"></a>
|
|
99
100
|
|
|
100
101
|
### module.exports#grid\_set\_caption(_grid, data) ⏏
|
|
102
|
+
Adding the row count number to the caption
|
|
103
|
+
|
|
101
104
|
**Kind**: Exported function
|
|
102
105
|
|
|
103
106
|
| Param | Type | Description |
|
|
@@ -345,7 +348,7 @@ Convert a cell into a link/url with data from another cell
|
|
|
345
348
|
**Example**
|
|
346
349
|
```js
|
|
347
350
|
var jqu = new Jqgrid_utils();
|
|
348
|
-
col_model = await jqu.add_link_details(col_model,'http://foo.bar'
|
|
351
|
+
col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
|
|
349
352
|
```
|
|
350
353
|
<a name="exp_module_Jqgrid_utils--module.exports+add_link_details_separator"></a>
|
|
351
354
|
|
|
@@ -365,7 +368,33 @@ Convert a cell into seperated based link/url like https://foo.bar.com/field/valu
|
|
|
365
368
|
**Example**
|
|
366
369
|
```js
|
|
367
370
|
var jqu = new Jqgrid_utils();
|
|
368
|
-
col_model = await jqu.add_link_details_separator(col_model,
|
|
371
|
+
col_model = await jqu.add_link_details_separator(col_model, url1 , 'style','target="_blank"',{"pricelist":"pricelist","style":"style"});
|
|
372
|
+
col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'target_column','target="_blank"',{"mykey":"myval"});
|
|
373
|
+
```
|
|
374
|
+
<a name="exp_module_Jqgrid_utils--module.exports+add_link_separator"></a>
|
|
375
|
+
|
|
376
|
+
### module.exports#add\_link\_separator(col_model, url, edit_field, fields) ⏏
|
|
377
|
+
Convert a cell into seperated based link/url include parameter based url like https://foo.bar.com/field.html?k=v
|
|
378
|
+
|
|
379
|
+
**Kind**: Exported function
|
|
380
|
+
|
|
381
|
+
| Param | Type | Description |
|
|
382
|
+
| --- | --- | --- |
|
|
383
|
+
| col_model | <code>object</code> | col_model of the grid |
|
|
384
|
+
| url | <code>string</code> | URL string |
|
|
385
|
+
| edit_field | <code>array</code> | array of dict |
|
|
386
|
+
| fields | <code>string</code> | URL Attributes |
|
|
387
|
+
|
|
388
|
+
**Example**
|
|
389
|
+
```js
|
|
390
|
+
var jqu = new Jqgrid_utils();
|
|
391
|
+
col_model = await jqu.add_link_separator(col_model, host + '/html' , 'style',[
|
|
392
|
+
{
|
|
393
|
+
'field':'pricelist',
|
|
394
|
+
'extension':'.html',
|
|
395
|
+
'fields':{'style':'style'}
|
|
396
|
+
}
|
|
397
|
+
]);
|
|
369
398
|
```
|
|
370
399
|
<a name="exp_module_Jqgrid_utils--module.exports+__cell_format"></a>
|
|
371
400
|
|
package/dist/jqgrid_utils.js
CHANGED
|
@@ -70,6 +70,7 @@ loadComplete: function(){
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
+
Adding the row count number to the caption
|
|
73
74
|
@alias module:Jqgrid_utils
|
|
74
75
|
@param {object} - gridobject;
|
|
75
76
|
@param {object} - grid data (optional);
|
|
@@ -94,7 +95,7 @@ loadComplete: function(){
|
|
|
94
95
|
let caption = grid.jqGrid("getGridParam", "caption");
|
|
95
96
|
const reg = /\d.*x/;
|
|
96
97
|
const new_caption = caption.replace(reg, "");
|
|
97
|
-
grid.jqGrid('setCaption', new_caption + count + 'x');
|
|
98
|
+
grid.jqGrid('setCaption', new_caption + " " + count + 'x');
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
/**
|
|
@@ -175,12 +176,12 @@ col_model = await jqu.resize_saved_cell_width(col_model);
|
|
|
175
176
|
@param {object} - row object
|
|
176
177
|
@param {string} - url of the API
|
|
177
178
|
@param {string} - data oject
|
|
178
|
-
@returns {object} {update: 'ok'} or {
|
|
179
|
+
@returns {object} {update: 'ok'} or {update: 'failed'}
|
|
179
180
|
@example
|
|
180
181
|
var jqu = new Jqgrid_utils();
|
|
181
182
|
afterSetRow: async function(row)
|
|
182
183
|
{
|
|
183
|
-
let r = await jqu.upsert_row(row,
|
|
184
|
+
let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
|
|
184
185
|
console.log(r);
|
|
185
186
|
},
|
|
186
187
|
*/
|
|
@@ -209,7 +210,7 @@ async upsert_row(row, url, req = {})
|
|
|
209
210
|
var jqu = new Jqgrid_utils();
|
|
210
211
|
afterSetRow: async function(row)
|
|
211
212
|
{
|
|
212
|
-
let r = await jqu.
|
|
213
|
+
let r = await jqu.insert_row(row, 'http://api.com');
|
|
213
214
|
console.log(r);
|
|
214
215
|
},
|
|
215
216
|
*/
|
|
@@ -245,7 +246,7 @@ async insert_row(row, url)
|
|
|
245
246
|
var jqu = new Jqgrid_utils();
|
|
246
247
|
afterSetRow: async function(row)
|
|
247
248
|
{
|
|
248
|
-
let r = await jqu.
|
|
249
|
+
let r = await jqu.update_row(row, 'http://api.com',{'key':value});
|
|
249
250
|
console.log(r);
|
|
250
251
|
},
|
|
251
252
|
*/
|
|
@@ -280,7 +281,7 @@ async update_row(row, url, req = {})
|
|
|
280
281
|
var jqu = new Jqgrid_utils();
|
|
281
282
|
afterDelRow: async function(row)
|
|
282
283
|
{
|
|
283
|
-
const r = await jqu.delete_row(
|
|
284
|
+
const r = await jqu.delete_row('id', 'http://api.com');
|
|
284
285
|
console.log(r + ' : ' + row + ' - from API');
|
|
285
286
|
},
|
|
286
287
|
*/
|
|
@@ -306,6 +307,7 @@ async delete_row(_id, url)
|
|
|
306
307
|
* Async Delete request used by function delete_row
|
|
307
308
|
@alias module:Jqgrid_utils
|
|
308
309
|
@param {string} - url of the API
|
|
310
|
+
@param {boalan} - header should be json type? default form type
|
|
309
311
|
@returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
|
|
310
312
|
@example
|
|
311
313
|
var jqu = new Jqgrid_utils();
|
|
@@ -414,7 +416,7 @@ async hide_del_icon()
|
|
|
414
416
|
@param {object} - keys and fields value to use
|
|
415
417
|
@example
|
|
416
418
|
var jqu = new Jqgrid_utils();
|
|
417
|
-
col_model = await jqu.add_link_details(col_model,'http://foo.bar'
|
|
419
|
+
col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
|
|
418
420
|
*/
|
|
419
421
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
420
422
|
{
|
|
@@ -493,7 +495,8 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
493
495
|
@param {object} - keys and fields value to use
|
|
494
496
|
@example
|
|
495
497
|
var jqu = new Jqgrid_utils();
|
|
496
|
-
col_model = await jqu.add_link_details_separator(col_model,
|
|
498
|
+
col_model = await jqu.add_link_details_separator(col_model, url1 , 'style','target="_blank"',{"pricelist":"pricelist","style":"style"});
|
|
499
|
+
col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'target_column','target="_blank"',{"mykey":"myval"});
|
|
497
500
|
*/
|
|
498
501
|
async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
|
|
499
502
|
{
|
|
@@ -522,7 +525,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
522
525
|
{
|
|
523
526
|
if(key != '')
|
|
524
527
|
{
|
|
525
|
-
pref += key + '' + '/' + encodeURIComponent(key_val);
|
|
528
|
+
pref += key + '' + '/' + encodeURIComponent(key_val) + '/';
|
|
526
529
|
}
|
|
527
530
|
else
|
|
528
531
|
{
|
|
@@ -533,7 +536,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
533
536
|
}
|
|
534
537
|
if (pref)
|
|
535
538
|
{
|
|
536
|
-
if (pref.slice(-1) === '&')
|
|
539
|
+
if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
|
|
537
540
|
{
|
|
538
541
|
pref = pref.slice(0, -1);
|
|
539
542
|
}
|
|
@@ -554,8 +557,76 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
554
557
|
|
|
555
558
|
|
|
556
559
|
|
|
560
|
+
/**
|
|
561
|
+
* Convert a cell into seperated based link/url include parameter based url like https://foo.bar.com/field.html?k=v
|
|
562
|
+
@alias module:Jqgrid_utils
|
|
563
|
+
@param {object} - col_model of the grid
|
|
564
|
+
@param {string} - URL string
|
|
565
|
+
@param {array} - array of dict
|
|
566
|
+
@param {string} - URL Attributes
|
|
567
|
+
@example
|
|
568
|
+
var jqu = new Jqgrid_utils();
|
|
569
|
+
col_model = await jqu.add_link_separator(col_model, host + '/html' , 'style',[
|
|
570
|
+
{
|
|
571
|
+
'field':'pricelist',
|
|
572
|
+
'extension':'.html',
|
|
573
|
+
'fields':{'style':'style'}
|
|
574
|
+
}
|
|
575
|
+
]);
|
|
576
|
+
|
|
577
|
+
*/
|
|
578
|
+
async add_link_separator(col_model, url, edit_field, fields, attr='')
|
|
579
|
+
{
|
|
580
|
+
url = url + '/';
|
|
581
|
+
let self = this;
|
|
582
|
+
for (let i = 0; i < col_model.length; i++)
|
|
583
|
+
{
|
|
584
|
+
if (col_model[i]['name'] === edit_field)
|
|
585
|
+
{
|
|
586
|
+
col_model[i]['formatter'] = function(cell_val, obj)
|
|
587
|
+
{
|
|
588
|
+
let key_val = cell_val;
|
|
589
|
+
let pref = '';
|
|
590
|
+
for(let x in fields)
|
|
591
|
+
{
|
|
592
|
+
for(let xx in fields[x])
|
|
593
|
+
{
|
|
594
|
+
if(xx === 'field')
|
|
595
|
+
{
|
|
596
|
+
let field_value = obj.rowData[fields[x][xx]];
|
|
597
|
+
pref += field_value;
|
|
598
|
+
}
|
|
599
|
+
if(xx === 'extension')
|
|
600
|
+
{
|
|
601
|
+
pref += fields[x][xx] ;
|
|
602
|
+
}
|
|
603
|
+
if(xx === 'fields')
|
|
604
|
+
{
|
|
605
|
+
pref += '?';
|
|
606
|
+
for(let key in fields[x][xx])
|
|
607
|
+
{
|
|
608
|
+
let val = obj.rowData[fields[x][xx][key]];
|
|
609
|
+
pref = pref + '' + key + '=' + encodeURIComponent(val) + '&';
|
|
610
|
+
}
|
|
611
|
+
}
|
|
557
612
|
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
if (pref)
|
|
616
|
+
{
|
|
617
|
+
if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
|
|
618
|
+
{
|
|
619
|
+
pref = pref.slice(0, -1);
|
|
620
|
+
}
|
|
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
|
@@ -69,6 +69,7 @@ loadComplete: function(){
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
+
Adding the row count number to the caption
|
|
72
73
|
@alias module:Jqgrid_utils
|
|
73
74
|
@param {object} - gridobject;
|
|
74
75
|
@param {object} - grid data (optional);
|
|
@@ -93,7 +94,7 @@ loadComplete: function(){
|
|
|
93
94
|
let caption = grid.jqGrid("getGridParam", "caption");
|
|
94
95
|
const reg = /\d.*x/;
|
|
95
96
|
const new_caption = caption.replace(reg, "");
|
|
96
|
-
grid.jqGrid('setCaption', new_caption + count + 'x');
|
|
97
|
+
grid.jqGrid('setCaption', new_caption + " " + count + 'x');
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
/**
|
|
@@ -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,76 @@ 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
|
+
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