jqgrid_utils 1.2.3 → 1.2.4

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.
@@ -78,8 +78,15 @@ module.exports = class Vanilla_website_utils
78
78
  {
79
79
  this.grid_set_captain(col_model, page, grid);
80
80
  }
81
+
82
+
81
83
  /**
82
84
  @alias module:Vanilla_website_utils
85
+ @param {object} - col_model for the grid
86
+ @param {string} - page
87
+ @param {object} - grid
88
+ @example
89
+ * col_model = await jqu.resize_saved_cell_width(col_model);
83
90
  */
84
91
  async resize_saved_cell_width(col_model,page=false, grid=false)
85
92
  {
@@ -87,10 +94,17 @@ module.exports = class Vanilla_website_utils
87
94
  key += grid ? '-' + grid + '-w-' : '-grid-w-';
88
95
  for(let x = 0; x<= col_model.length; x++)
89
96
  {
90
- const width = localStorage.getItem(key + x);
91
- if(width)
97
+ if(col_model[x])
92
98
  {
93
- col_model[x]['width'] = width;
99
+ if(col_model[x]['name'])
100
+ {
101
+ const name = col_model[x]['name'];
102
+ const width = localStorage.getItem(key + name);
103
+ if(width)
104
+ {
105
+ col_model[x]['width'] = width;
106
+ }
107
+ }
94
108
  }
95
109
  }
96
110
  return col_model;
@@ -98,16 +112,30 @@ module.exports = class Vanilla_website_utils
98
112
 
99
113
  /**
100
114
  @alias module:Vanilla_website_utils
115
+ * resize_cell
116
+ * call after resize a column
117
+ @param {string} - width - the size of the resized column
118
+ @param {string} - index - column number what get resized
119
+ @param {string} - _page - not in use yet
120
+ @example
121
+ * var jqu = new Jqgrid_utils({page:'mypage'});
122
+ * resizeStop: jqu.resize_cell,
101
123
  */
102
124
  resize_cell(width, index, _page=false)
103
125
  {
104
- const page = _page ? _page : localStorage.getItem('page');
105
- const grid = this.id;
106
- let idx = index-1;
107
- let key = page + '-' + grid + '-w-' + idx;
108
- localStorage.setItem(key, width);
109
- const cat = localStorage.getItem(key);
110
- console.log(key);
126
+ const col_model = jQuery(this).jqGrid ('getGridParam', 'colModel');
127
+ if(col_model[index])
128
+ {
129
+ if(col_model[index]['name'])
130
+ {
131
+ const name = col_model[index]['name'];
132
+ const page = _page ? _page : localStorage.getItem('page');
133
+ const grid = this.id;
134
+ let key = page + '-' + grid + '-w-' + name;
135
+ localStorage.setItem(key, width);
136
+ const cat = localStorage.getItem(key);
137
+ }
138
+ }
111
139
  }
112
140
 
113
141
 
package/jqgrid_utils.js CHANGED
@@ -77,8 +77,15 @@ module.exports = class Vanilla_website_utils
77
77
  {
78
78
  this.grid_set_captain(col_model, page, grid);
79
79
  }
80
+
81
+
80
82
  /**
81
83
  @alias module:Vanilla_website_utils
84
+ @param {object} - col_model for the grid
85
+ @param {string} - page
86
+ @param {object} - grid
87
+ @example
88
+ * col_model = await jqu.resize_saved_cell_width(col_model);
82
89
  */
83
90
  async resize_saved_cell_width(col_model,page=false, grid=false)
84
91
  {
@@ -86,10 +93,17 @@ module.exports = class Vanilla_website_utils
86
93
  key += grid ? '-' + grid + '-w-' : '-grid-w-';
87
94
  for(let x = 0; x<= col_model.length; x++)
88
95
  {
89
- const width = localStorage.getItem(key + x);
90
- if(width)
96
+ if(col_model[x])
91
97
  {
92
- col_model[x]['width'] = width;
98
+ if(col_model[x]['name'])
99
+ {
100
+ const name = col_model[x]['name'];
101
+ const width = localStorage.getItem(key + name);
102
+ if(width)
103
+ {
104
+ col_model[x]['width'] = width;
105
+ }
106
+ }
93
107
  }
94
108
  }
95
109
  return col_model;
@@ -97,16 +111,30 @@ module.exports = class Vanilla_website_utils
97
111
 
98
112
  /**
99
113
  @alias module:Vanilla_website_utils
114
+ * resize_cell
115
+ * call after resize a column
116
+ @param {string} - width - the size of the resized column
117
+ @param {string} - index - column number what get resized
118
+ @param {string} - _page - not in use yet
119
+ @example
120
+ * var jqu = new Jqgrid_utils({page:'mypage'});
121
+ * resizeStop: jqu.resize_cell,
100
122
  */
101
123
  resize_cell(width, index, _page=false)
102
124
  {
103
- const page = _page ? _page : localStorage.getItem('page');
104
- const grid = this.id;
105
- let idx = index-1;
106
- let key = page + '-' + grid + '-w-' + idx;
107
- localStorage.setItem(key, width);
108
- const cat = localStorage.getItem(key);
109
- console.log(key);
125
+ const col_model = jQuery(this).jqGrid ('getGridParam', 'colModel');
126
+ if(col_model[index])
127
+ {
128
+ if(col_model[index]['name'])
129
+ {
130
+ const name = col_model[index]['name'];
131
+ const page = _page ? _page : localStorage.getItem('page');
132
+ const grid = this.id;
133
+ let key = page + '-' + grid + '-w-' + name;
134
+ localStorage.setItem(key, width);
135
+ const cat = localStorage.getItem(key);
136
+ }
137
+ }
110
138
  }
111
139
 
112
140
 
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.3"
32
+ "version": "1.2.4"
33
33
  }