jqgrid_utils 1.2.11 → 1.2.15
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 +50 -2
- package/dist/jqgrid_utils.js +119 -0
- package/jqgrid_utils.js +119 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ A module for Jqgrid_utils
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
* [Jqgrid_utils](#module_Jqgrid_utils)
|
|
39
|
-
* [module.exports#set_link()](#exp_module_Jqgrid_utils--module.exports+set_link) ⏏
|
|
39
|
+
* [module.exports#set_link(col_model, edit_field, url)](#exp_module_Jqgrid_utils--module.exports+set_link) ⏏
|
|
40
40
|
* [module.exports#grid_set_caption(_grid, data)](#exp_module_Jqgrid_utils--module.exports+grid_set_caption) ⏏
|
|
41
41
|
* [module.exports#s_resize_saved_cell_width()](#exp_module_Jqgrid_utils--module.exports+s_resize_saved_cell_width) ⏏
|
|
42
42
|
* [module.exports#resize_saved_cell_width(col_model, page, grid)](#exp_module_Jqgrid_utils--module.exports+resize_saved_cell_width) ⏏
|
|
@@ -54,11 +54,27 @@ A module for Jqgrid_utils
|
|
|
54
54
|
* [module.exports#__cell_format()](#exp_module_Jqgrid_utils--module.exports+__cell_format) ⏏
|
|
55
55
|
* [module.exports#subgrid(_id, id, data_url, col_model, caption)](#exp_module_Jqgrid_utils--module.exports+subgrid) ⏏
|
|
56
56
|
* [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Jqgrid_utils--module.exports+add_image) ⏏
|
|
57
|
+
* [module.exports#set_filter(grid, data, fx, append_to)](#exp_module_Jqgrid_utils--module.exports+set_filter) ⏏
|
|
58
|
+
* [module.exports#_filter()](#exp_module_Jqgrid_utils--module.exports+_filter) ⏏
|
|
57
59
|
|
|
58
60
|
<a name="exp_module_Jqgrid_utils--module.exports+set_link"></a>
|
|
59
61
|
|
|
60
|
-
### module.exports#set\_link() ⏏
|
|
62
|
+
### module.exports#set\_link(col_model, edit_field, url) ⏏
|
|
63
|
+
Add an URL from the data to a specific cell/column
|
|
64
|
+
|
|
61
65
|
**Kind**: Exported function
|
|
66
|
+
**Result**: https://foo.bar.com/av0_code/bar
|
|
67
|
+
|
|
68
|
+
| Param | Type | Description |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| col_model | <code>object</code> | col_model of the grid |
|
|
71
|
+
| edit_field | <code>string</code> | name of the column what should get convert to the url |
|
|
72
|
+
| url | <code>string</code> | the used url of the data |
|
|
73
|
+
|
|
74
|
+
**Example**
|
|
75
|
+
```js
|
|
76
|
+
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
|
|
77
|
+
```
|
|
62
78
|
<a name="exp_module_Jqgrid_utils--module.exports+grid_set_caption"></a>
|
|
63
79
|
|
|
64
80
|
### module.exports#grid\_set\_caption(_grid, data) ⏏
|
|
@@ -198,3 +214,35 @@ let col_model = JSON.parse(await vwu.aget_api(col_model_url))
|
|
|
198
214
|
```js
|
|
199
215
|
col_model = await jqu.add_image(col_model, 'image', 60, false);
|
|
200
216
|
```
|
|
217
|
+
<a name="exp_module_Jqgrid_utils--module.exports+set_filter"></a>
|
|
218
|
+
|
|
219
|
+
### module.exports#set\_filter(grid, data, fx, append_to) ⏏
|
|
220
|
+
Add a filter to the website beside the grid
|
|
221
|
+
|
|
222
|
+
**Kind**: Exported function
|
|
223
|
+
|
|
224
|
+
| Param | Type | Default | Description |
|
|
225
|
+
| --- | --- | --- | --- |
|
|
226
|
+
| grid | <code>object</code> | | grid object or grid string name |
|
|
227
|
+
| data | <code>object</code> | | the grid data object |
|
|
228
|
+
| fx | <code>object</code> | | a dict with a array what should be filterd by the grid |
|
|
229
|
+
| append_to | <code>string</code> | <code>"#filter"</code> | id name of the DOM oject where the filter should be appened |
|
|
230
|
+
|
|
231
|
+
**Example**
|
|
232
|
+
```js
|
|
233
|
+
var jqu = new Jqgrid_utils();
|
|
234
|
+
var run_me_once = true;
|
|
235
|
+
gridComplete: async function(){
|
|
236
|
+
if(run_me_once)
|
|
237
|
+
{
|
|
238
|
+
await jqu.set_filter(this, data, {material:[],section:[]}, '#filter');
|
|
239
|
+
run_me_once = false;
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
```
|
|
243
|
+
<a name="exp_module_Jqgrid_utils--module.exports+_filter"></a>
|
|
244
|
+
|
|
245
|
+
### module.exports#\_filter() ⏏
|
|
246
|
+
private function of set_filter
|
|
247
|
+
|
|
248
|
+
**Kind**: Exported function
|
package/dist/jqgrid_utils.js
CHANGED
|
@@ -28,7 +28,15 @@ module.exports = class Vanilla_website_utils
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
+
* Add an URL from the data to a specific cell/column
|
|
31
32
|
@alias module:Jqgrid_utils
|
|
33
|
+
@param {object} - col_model of the grid
|
|
34
|
+
@param {string} - name of the column what should get convert to the url
|
|
35
|
+
@param {string} - the used url of the data
|
|
36
|
+
@example
|
|
37
|
+
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
|
|
38
|
+
@result
|
|
39
|
+
* https://foo.bar.com/av0_code/bar
|
|
32
40
|
*/
|
|
33
41
|
async set_link(col_model, edit_field, url ,attr='')
|
|
34
42
|
{
|
|
@@ -545,6 +553,117 @@ async add_image(col_model, edit_field, size, link=false)
|
|
|
545
553
|
|
|
546
554
|
|
|
547
555
|
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Add a filter to the website beside the grid
|
|
559
|
+
@alias module:Jqgrid_utils
|
|
560
|
+
@param {object} - grid object or grid string name
|
|
561
|
+
@param {object} - the grid data object
|
|
562
|
+
@param {object} - a dict with a array what should be filterd by the grid
|
|
563
|
+
@param {string} - id name of the DOM oject where the filter should be appened
|
|
564
|
+
@example
|
|
565
|
+
var jqu = new Jqgrid_utils();
|
|
566
|
+
var run_me_once = true;
|
|
567
|
+
gridComplete: async function(){
|
|
568
|
+
if(run_me_once)
|
|
569
|
+
{
|
|
570
|
+
await jqu.set_filter(this, data, {material:[],section:[]}, '#filter');
|
|
571
|
+
run_me_once = false;
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
*/
|
|
575
|
+
async set_filter(grid, data, fx, append_to="#filter")
|
|
576
|
+
{
|
|
577
|
+
jQuery(grid).jqGrid('setGridParam', { fdata: data });
|
|
578
|
+
let f = document.querySelector(append_to);
|
|
579
|
+
for(const i in data)
|
|
580
|
+
{
|
|
581
|
+
for(let x in fx)
|
|
582
|
+
{
|
|
583
|
+
fx[x].push(data[i][x]);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
for(let x in fx)
|
|
588
|
+
{
|
|
589
|
+
fx[x]= fx[x].filter((val, ind, arr) => arr.indexOf(val) === ind);
|
|
590
|
+
fx[x].sort();
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
for(let x in fx)
|
|
594
|
+
{
|
|
595
|
+
let ul = document.createElement('ul');
|
|
596
|
+
let lh = document.createElement('lh');
|
|
597
|
+
lh.innerHTML = x;
|
|
598
|
+
ul.appendChild(lh);
|
|
599
|
+
for(let i in fx[x])
|
|
600
|
+
{
|
|
601
|
+
let li = document.createElement('li');
|
|
602
|
+
let l = document.createElement('label');
|
|
603
|
+
l.innerHTML = fx[x][i];
|
|
604
|
+
let c = document.createElement('input');
|
|
605
|
+
c.setAttribute('type','checkbox');
|
|
606
|
+
c.setAttribute('class',x);
|
|
607
|
+
c.setAttribute('id', x + '_' + fx[x][i]);
|
|
608
|
+
l.setAttribute('for',x + '_' + fx[x][i]);
|
|
609
|
+
c.value = fx[x][i];
|
|
610
|
+
c.onchange = async () => { await this._filter(grid,fx);};
|
|
611
|
+
li.appendChild(l);
|
|
612
|
+
li.appendChild(c);
|
|
613
|
+
ul.appendChild(li);
|
|
614
|
+
}
|
|
615
|
+
f.appendChild(ul);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* private function of set_filter
|
|
622
|
+
@alias module:Jqgrid_utils
|
|
623
|
+
*/
|
|
624
|
+
async _filter(grid, fx)
|
|
625
|
+
{
|
|
626
|
+
let _data = [];
|
|
627
|
+
let data = jQuery(grid).jqGrid('getGridParam','fdata');
|
|
628
|
+
let filter = [];
|
|
629
|
+
for(let x in fx)
|
|
630
|
+
{
|
|
631
|
+
let m = document.querySelectorAll("." + x);
|
|
632
|
+
filter[x] = [];
|
|
633
|
+
for(let i in m)
|
|
634
|
+
{
|
|
635
|
+
if(m[i].checked)
|
|
636
|
+
{
|
|
637
|
+
filter[x].push(m[i].value);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
for(let i in data)
|
|
642
|
+
{
|
|
643
|
+
let include = false;
|
|
644
|
+
for(let x in fx)
|
|
645
|
+
{
|
|
646
|
+
if(filter[x].indexOf(data[i][x]) != -1)
|
|
647
|
+
{
|
|
648
|
+
include = true;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
if(include)
|
|
652
|
+
{
|
|
653
|
+
_data.push(data[i]);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
jQuery(grid).jqGrid('clearGridData');
|
|
657
|
+
jQuery(grid).jqGrid('setGridParam', {data: _data});
|
|
658
|
+
jQuery(grid).trigger('reloadGrid');
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
|
|
548
667
|
};
|
|
549
668
|
|
|
550
669
|
|
package/jqgrid_utils.js
CHANGED
|
@@ -27,7 +27,15 @@ module.exports = class Vanilla_website_utils
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
+
* Add an URL from the data to a specific cell/column
|
|
30
31
|
@alias module:Jqgrid_utils
|
|
32
|
+
@param {object} - col_model of the grid
|
|
33
|
+
@param {string} - name of the column what should get convert to the url
|
|
34
|
+
@param {string} - the used url of the data
|
|
35
|
+
@example
|
|
36
|
+
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
|
|
37
|
+
@result
|
|
38
|
+
* https://foo.bar.com/av0_code/bar
|
|
31
39
|
*/
|
|
32
40
|
async set_link(col_model, edit_field, url ,attr='')
|
|
33
41
|
{
|
|
@@ -544,6 +552,117 @@ async add_image(col_model, edit_field, size, link=false)
|
|
|
544
552
|
|
|
545
553
|
|
|
546
554
|
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Add a filter to the website beside the grid
|
|
558
|
+
@alias module:Jqgrid_utils
|
|
559
|
+
@param {object} - grid object or grid string name
|
|
560
|
+
@param {object} - the grid data object
|
|
561
|
+
@param {object} - a dict with a array what should be filterd by the grid
|
|
562
|
+
@param {string} - id name of the DOM oject where the filter should be appened
|
|
563
|
+
@example
|
|
564
|
+
var jqu = new Jqgrid_utils();
|
|
565
|
+
var run_me_once = true;
|
|
566
|
+
gridComplete: async function(){
|
|
567
|
+
if(run_me_once)
|
|
568
|
+
{
|
|
569
|
+
await jqu.set_filter(this, data, {material:[],section:[]}, '#filter');
|
|
570
|
+
run_me_once = false;
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
*/
|
|
574
|
+
async set_filter(grid, data, fx, append_to="#filter")
|
|
575
|
+
{
|
|
576
|
+
jQuery(grid).jqGrid('setGridParam', { fdata: data });
|
|
577
|
+
let f = document.querySelector(append_to);
|
|
578
|
+
for(const i in data)
|
|
579
|
+
{
|
|
580
|
+
for(let x in fx)
|
|
581
|
+
{
|
|
582
|
+
fx[x].push(data[i][x]);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
for(let x in fx)
|
|
587
|
+
{
|
|
588
|
+
fx[x]= fx[x].filter((val, ind, arr) => arr.indexOf(val) === ind);
|
|
589
|
+
fx[x].sort();
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
for(let x in fx)
|
|
593
|
+
{
|
|
594
|
+
let ul = document.createElement('ul');
|
|
595
|
+
let lh = document.createElement('lh');
|
|
596
|
+
lh.innerHTML = x;
|
|
597
|
+
ul.appendChild(lh);
|
|
598
|
+
for(let i in fx[x])
|
|
599
|
+
{
|
|
600
|
+
let li = document.createElement('li');
|
|
601
|
+
let l = document.createElement('label');
|
|
602
|
+
l.innerHTML = fx[x][i];
|
|
603
|
+
let c = document.createElement('input');
|
|
604
|
+
c.setAttribute('type','checkbox');
|
|
605
|
+
c.setAttribute('class',x);
|
|
606
|
+
c.setAttribute('id', x + '_' + fx[x][i]);
|
|
607
|
+
l.setAttribute('for',x + '_' + fx[x][i]);
|
|
608
|
+
c.value = fx[x][i];
|
|
609
|
+
c.onchange = async () => { await this._filter(grid,fx);};
|
|
610
|
+
li.appendChild(l);
|
|
611
|
+
li.appendChild(c);
|
|
612
|
+
ul.appendChild(li);
|
|
613
|
+
}
|
|
614
|
+
f.appendChild(ul);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* private function of set_filter
|
|
621
|
+
@alias module:Jqgrid_utils
|
|
622
|
+
*/
|
|
623
|
+
async _filter(grid, fx)
|
|
624
|
+
{
|
|
625
|
+
let _data = [];
|
|
626
|
+
let data = jQuery(grid).jqGrid('getGridParam','fdata');
|
|
627
|
+
let filter = [];
|
|
628
|
+
for(let x in fx)
|
|
629
|
+
{
|
|
630
|
+
let m = document.querySelectorAll("." + x);
|
|
631
|
+
filter[x] = [];
|
|
632
|
+
for(let i in m)
|
|
633
|
+
{
|
|
634
|
+
if(m[i].checked)
|
|
635
|
+
{
|
|
636
|
+
filter[x].push(m[i].value);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
for(let i in data)
|
|
641
|
+
{
|
|
642
|
+
let include = false;
|
|
643
|
+
for(let x in fx)
|
|
644
|
+
{
|
|
645
|
+
if(filter[x].indexOf(data[i][x]) != -1)
|
|
646
|
+
{
|
|
647
|
+
include = true;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if(include)
|
|
651
|
+
{
|
|
652
|
+
_data.push(data[i]);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
jQuery(grid).jqGrid('clearGridData');
|
|
656
|
+
jQuery(grid).jqGrid('setGridParam', {data: _data});
|
|
657
|
+
jQuery(grid).trigger('reloadGrid');
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
|
|
547
666
|
};
|
|
548
667
|
|
|
549
668
|
|
package/package.json
CHANGED