jqgrid_utils 1.0.4 → 1.1.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.
@@ -4,26 +4,97 @@
4
4
  module.exports = class Vanilla_website_utils
5
5
  {
6
6
 
7
- constructor()
8
- {}
9
-
10
- s_grid_set_captain(_grid, data=[])
11
- {
12
- this.grid_set_captain(_grid, data=[]);
13
- }
14
- async grid_set_captain(_grid, data=[])
7
+ constructor(settings=false)
8
+ {
9
+ if(settings)
15
10
  {
16
- const grid = jQuery(_grid);
17
- if(data.length ===0)
11
+ if(settings.hasOwnProperty('page'))
18
12
  {
19
- data = grid.jqGrid('getRowData');
13
+ this.page = settings['page'];
14
+ localStorage.setItem('page', this.page);
20
15
  }
21
- let caption = grid.jqGrid("getGridParam", "caption");
22
- if (Array.isArray(data))
16
+ }
17
+
18
+ }
19
+
20
+ async s_set_link(col_model, edit_field, url ,attr='')
21
+ {
22
+ this.set_link(col_model, edit_field, url ,attr);
23
+ }
24
+
25
+
26
+ async set_link(col_model, edit_field, url ,attr='')
27
+ {
28
+ for(let i=0;i< col_model.length;i++)
29
+ {
30
+ if(col_model[i]['name'] === edit_field)
23
31
  {
24
- grid.jqGrid('setCaption', caption + ' - ' + data.length + 'x');
32
+ col_model[i]['formatter'] = function (cell_val,o)
33
+ {
34
+ return '<a class="gl" ' + attr + 'href="' + o.rowData[url] + '">'+ cell_val +'</a>';
35
+ };
25
36
  }
26
37
  }
38
+ return col_model;
39
+ }
40
+
41
+
42
+ s_grid_set_captain(_grid, data=[])
43
+ {
44
+ this.grid_set_captain(_grid, data=[]);
45
+ }
46
+ async grid_set_captain(_grid, data=[])
47
+ {
48
+ const grid = jQuery(_grid);
49
+ let count = 0;
50
+ if(data.length === 0)
51
+ {
52
+ count = grid.jqGrid('getGridParam', 'records');
53
+ }
54
+ else
55
+ {
56
+ count = data.length;
57
+ }
58
+ let caption = grid.jqGrid("getGridParam", "caption");
59
+ if(caption.indexOf(count+'x') === -1 )
60
+ {
61
+ grid.jqGrid('setCaption', caption + ' - ' + count + 'x');
62
+ }
63
+ }
64
+
65
+
66
+ s_resize_saved_cell_width(col_model, page=false, grid=false)
67
+ {
68
+ this.grid_set_captain(col_model, page, grid);
69
+ }
70
+
71
+ async resize_saved_cell_width(col_model,page=false, grid=false)
72
+ {
73
+ let key = page ? page : this.page;
74
+ key += grid ? '-' + grid + '-w-' : '-grid-w-';
75
+ for(let x = 0; x<= col_model.length; x++)
76
+ {
77
+ const width = localStorage.getItem(key + x);
78
+ if(width)
79
+ {
80
+ col_model[x]['width'] = width;
81
+ }
82
+ }
83
+ return col_model;
84
+ }
85
+
86
+
87
+ resize_cell(width, index, _page=false)
88
+ {
89
+ const page = _page ? _page : localStorage.getItem('page');
90
+ const grid = this.id;
91
+ let idx = index-1;
92
+ let key = page + '-' + grid + '-w-' + idx;
93
+ localStorage.setItem(key, width);
94
+ const cat = localStorage.getItem(key);
95
+ console.log(key);
96
+ }
97
+
27
98
 
28
99
 
29
100
  };
package/jqgrid_utils.js CHANGED
@@ -3,26 +3,97 @@
3
3
  module.exports = class Vanilla_website_utils
4
4
  {
5
5
 
6
- constructor()
7
- {}
8
-
9
- s_grid_set_captain(_grid, data=[])
10
- {
11
- this.grid_set_captain(_grid, data=[]);
12
- }
13
- async grid_set_captain(_grid, data=[])
6
+ constructor(settings=false)
7
+ {
8
+ if(settings)
14
9
  {
15
- const grid = jQuery(_grid);
16
- if(data.length ===0)
10
+ if(settings.hasOwnProperty('page'))
17
11
  {
18
- data = grid.jqGrid('getRowData');
12
+ this.page = settings['page'];
13
+ localStorage.setItem('page', this.page);
19
14
  }
20
- let caption = grid.jqGrid("getGridParam", "caption");
21
- if (Array.isArray(data))
15
+ }
16
+
17
+ }
18
+
19
+ async s_set_link(col_model, edit_field, url ,attr='')
20
+ {
21
+ this.set_link(col_model, edit_field, url ,attr);
22
+ }
23
+
24
+
25
+ async set_link(col_model, edit_field, url ,attr='')
26
+ {
27
+ for(let i=0;i< col_model.length;i++)
28
+ {
29
+ if(col_model[i]['name'] === edit_field)
22
30
  {
23
- grid.jqGrid('setCaption', caption + ' - ' + data.length + 'x');
31
+ col_model[i]['formatter'] = function (cell_val,o)
32
+ {
33
+ return '<a class="gl" ' + attr + 'href="' + o.rowData[url] + '">'+ cell_val +'</a>';
34
+ };
24
35
  }
25
36
  }
37
+ return col_model;
38
+ }
39
+
40
+
41
+ s_grid_set_captain(_grid, data=[])
42
+ {
43
+ this.grid_set_captain(_grid, data=[]);
44
+ }
45
+ async grid_set_captain(_grid, data=[])
46
+ {
47
+ const grid = jQuery(_grid);
48
+ let count = 0;
49
+ if(data.length === 0)
50
+ {
51
+ count = grid.jqGrid('getGridParam', 'records');
52
+ }
53
+ else
54
+ {
55
+ count = data.length;
56
+ }
57
+ let caption = grid.jqGrid("getGridParam", "caption");
58
+ if(caption.indexOf(count+'x') === -1 )
59
+ {
60
+ grid.jqGrid('setCaption', caption + ' - ' + count + 'x');
61
+ }
62
+ }
63
+
64
+
65
+ s_resize_saved_cell_width(col_model, page=false, grid=false)
66
+ {
67
+ this.grid_set_captain(col_model, page, grid);
68
+ }
69
+
70
+ async resize_saved_cell_width(col_model,page=false, grid=false)
71
+ {
72
+ let key = page ? page : this.page;
73
+ key += grid ? '-' + grid + '-w-' : '-grid-w-';
74
+ for(let x = 0; x<= col_model.length; x++)
75
+ {
76
+ const width = localStorage.getItem(key + x);
77
+ if(width)
78
+ {
79
+ col_model[x]['width'] = width;
80
+ }
81
+ }
82
+ return col_model;
83
+ }
84
+
85
+
86
+ resize_cell(width, index, _page=false)
87
+ {
88
+ const page = _page ? _page : localStorage.getItem('page');
89
+ const grid = this.id;
90
+ let idx = index-1;
91
+ let key = page + '-' + grid + '-w-' + idx;
92
+ localStorage.setItem(key, width);
93
+ const cat = localStorage.getItem(key);
94
+ console.log(key);
95
+ }
96
+
26
97
 
27
98
 
28
99
  };
package/make.sh CHANGED
@@ -1 +1,3 @@
1
+ cp npmignore .npmignore
2
+
1
3
  watchify jqgrid_utils.js --s Jqgrid_utils -o dist/jqgrid_utils.js -v
package/npmignore ADDED
@@ -0,0 +1,2 @@
1
+ .tern-port
2
+ *~
package/package.json CHANGED
@@ -6,8 +6,8 @@
6
6
  "dependencies":
7
7
  {},
8
8
  "deprecated": false,
9
- "description": "Convenient Functions for free jqGrid",
10
- "homepage": "https://calantas.org/jq_gridutils",
9
+ "description": "Convenient Functions for the Free jqGrid",
10
+ "homepage": "http://calantas.org/jqgrid_utils",
11
11
  "license": "GPL-3.0-or-later",
12
12
  "main": "jqgrid_utils.js",
13
13
  "name": "jqgrid_utils",
@@ -16,6 +16,7 @@
16
16
  "free-jqgrid",
17
17
  "utilities",
18
18
  "helpers",
19
+ "utils",
19
20
  "extend-jqgrid"
20
21
  ],
21
22
  "repository":
@@ -27,5 +28,5 @@
27
28
  {
28
29
  "test": "echo \"Error: no test specified\" && exit 1"
29
30
  },
30
- "version": "1.0.4"
31
+ "version": "1.1.2"
31
32
  }