jqgrid_utils 1.4.8 → 1.5.1

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 CHANGED
@@ -27,6 +27,7 @@ A module for Jqgrid_utils
27
27
 
28
28
 
29
29
  * [Jqgrid_utils](#module_Jqgrid_utils)
30
+ * [module.exports#get_col_model_from_data(obj, data, exclude, col_model)](#exp_module_Jqgrid_utils--module.exports+get_col_model_from_data) ⇒ <code>array</code> ⏏
30
31
  * [module.exports#_date112_to_DMY(cell_value, seperator)](#exp_module_Jqgrid_utils--module.exports+_date112_to_DMY) ⏏
31
32
  * [module.exports#date112_to_DMY(col_model, edit_field, seperator)](#exp_module_Jqgrid_utils--module.exports+date112_to_DMY) ⏏
32
33
  * [module.exports#add_ok_button(col_model, fields)](#exp_module_Jqgrid_utils--module.exports+add_ok_button) ⇒ <code>array</code> ⏏
@@ -57,6 +58,31 @@ A module for Jqgrid_utils
57
58
  * [module.exports#set_filter(grid, data, fx, append_to)](#exp_module_Jqgrid_utils--module.exports+set_filter) ⏏
58
59
  * [module.exports#_filter()](#exp_module_Jqgrid_utils--module.exports+_filter) ⏏
59
60
 
61
+ <a name="exp_module_Jqgrid_utils--module.exports+get_col_model_from_data"></a>
62
+
63
+ ### module.exports#get\_col\_model\_from\_data(obj, data, exclude, col_model) ⇒ <code>array</code> ⏏
64
+ Get basic colModel data from raw data
65
+
66
+ **Kind**: Exported function
67
+ **Returns**: <code>array</code> - - col_model
68
+
69
+ | Param | Type | Description |
70
+ | --- | --- | --- |
71
+ | obj | <code>array</code> | grid object |
72
+ | data | <code>array</code> | raw data object from loadComplete |
73
+ | exclude | <code>array</code> | list of columns to exclude (optional) |
74
+ | col_model | <code>array</code> | existing colModel (optional) |
75
+
76
+ **Example**
77
+ ```js
78
+ var jqu = new Jqgrid_utils();
79
+ ,loadComplete: async function(data)
80
+ {
81
+ let col_model = jQuery(this).jqGrid('getGridParam',"colModel");
82
+ const new_col_model= await update_col_model(this, data, ['id','cust_qty','waiting_supplier_orders','waiting_assemblies','pending_components','pending_customer_order',col_model);
83
+ jQuery(this).jqGrid('setGridParam',{colModel:new_col_model});
84
+ },
85
+ ```
60
86
  <a name="exp_module_Jqgrid_utils--module.exports+_date112_to_DMY"></a>
61
87
 
62
88
  ### module.exports#\_date112\_to\_DMY(cell_value, seperator) ⏏
@@ -459,6 +485,7 @@ Convert a cell into a link/url with data from another cell
459
485
  ```js
460
486
  var jqu = new Jqgrid_utils();
461
487
  col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
488
+ col_model = await jqu.add_link_details(col_model, host + '/html/table_size.html' , 'database','target="_blank"',{"database":"database","server":"server"});
462
489
  ```
463
490
  <a name="exp_module_Jqgrid_utils--module.exports+add_link_details_separator"></a>
464
491
 
@@ -22,6 +22,56 @@ module.exports = class Vanilla_website_utils
22
22
 
23
23
  }
24
24
 
25
+ /**
26
+ * Get basic colModel data from raw data
27
+ @alias module:Jqgrid_utils
28
+ @param {array} - grid object
29
+ @param {array} - raw data object from loadComplete
30
+ @param {array} - list of columns to exclude (optional)
31
+ @param {array} - existing colModel (optional)
32
+ @returns {array} - col_model
33
+ @example
34
+ var jqu = new Jqgrid_utils();
35
+ ,loadComplete: async function(data)
36
+ {
37
+ let col_model = jQuery(this).jqGrid('getGridParam',"colModel");
38
+ const new_col_model= await update_col_model(this, data, ['id','cust_qty','waiting_supplier_orders','waiting_assemblies','pending_components','pending_customer_order',col_model);
39
+ jQuery(this).jqGrid('setGridParam',{colModel:new_col_model});
40
+ },
41
+ */
42
+ async get_col_model_from_data(obj, data, exclude=[],col_model=[])
43
+ {
44
+ let cols = [];
45
+ for(let i in data)
46
+ {
47
+ const keys = Object.keys(data[i]);
48
+ for(let ii in keys)
49
+ {
50
+ const key = keys[ii];
51
+ cols.push(key);
52
+ }
53
+ }
54
+ cols = cols.filter((item, pos) => cols.indexOf(item) === pos);
55
+ let mcols = [];
56
+ for(let i in col_model)
57
+ {
58
+ mcols.push(col_model[i]['name']);
59
+ }
60
+
61
+
62
+ let diff = cols.filter(x => !mcols.includes(x));
63
+ const _exclude = new Set(exclude);
64
+ diff = diff.filter((name) => {return !_exclude.has(name); });
65
+ diff.sort();
66
+
67
+ for(let x=0; x < diff.length; x++)
68
+ {
69
+ col_model.push({'name': diff[x],'label': diff[x]});
70
+ }
71
+ //console.log(col_model);
72
+ return col_model;
73
+ }
74
+
25
75
 
26
76
  /**
27
77
  * Convert a 112 date string to a DMY format with sepertaor - sync function
@@ -626,6 +676,7 @@ async hide_del_icon()
626
676
  @example
627
677
  var jqu = new Jqgrid_utils();
628
678
  col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
679
+ col_model = await jqu.add_link_details(col_model, host + '/html/table_size.html' , 'database','target="_blank"',{"database":"database","server":"server"});
629
680
  */
630
681
  async add_link_details(col_model, url, edit_field, attr = '', keys, format)
631
682
  {
package/jqgrid_utils.js CHANGED
@@ -21,6 +21,56 @@ module.exports = class Vanilla_website_utils
21
21
 
22
22
  }
23
23
 
24
+ /**
25
+ * Get basic colModel data from raw data
26
+ @alias module:Jqgrid_utils
27
+ @param {array} - grid object
28
+ @param {array} - raw data object from loadComplete
29
+ @param {array} - list of columns to exclude (optional)
30
+ @param {array} - existing colModel (optional)
31
+ @returns {array} - col_model
32
+ @example
33
+ var jqu = new Jqgrid_utils();
34
+ ,loadComplete: async function(data)
35
+ {
36
+ let col_model = jQuery(this).jqGrid('getGridParam',"colModel");
37
+ const new_col_model= await update_col_model(this, data, ['id','cust_qty','waiting_supplier_orders','waiting_assemblies','pending_components','pending_customer_order',col_model);
38
+ jQuery(this).jqGrid('setGridParam',{colModel:new_col_model});
39
+ },
40
+ */
41
+ async get_col_model_from_data(obj, data, exclude=[],col_model=[])
42
+ {
43
+ let cols = [];
44
+ for(let i in data)
45
+ {
46
+ const keys = Object.keys(data[i]);
47
+ for(let ii in keys)
48
+ {
49
+ const key = keys[ii];
50
+ cols.push(key);
51
+ }
52
+ }
53
+ cols = cols.filter((item, pos) => cols.indexOf(item) === pos);
54
+ let mcols = [];
55
+ for(let i in col_model)
56
+ {
57
+ mcols.push(col_model[i]['name']);
58
+ }
59
+
60
+
61
+ let diff = cols.filter(x => !mcols.includes(x));
62
+ const _exclude = new Set(exclude);
63
+ diff = diff.filter((name) => {return !_exclude.has(name); });
64
+ diff.sort();
65
+
66
+ for(let x=0; x < diff.length; x++)
67
+ {
68
+ col_model.push({'name': diff[x],'label': diff[x]});
69
+ }
70
+ //console.log(col_model);
71
+ return col_model;
72
+ }
73
+
24
74
 
25
75
  /**
26
76
  * Convert a 112 date string to a DMY format with sepertaor - sync function
@@ -625,6 +675,7 @@ async hide_del_icon()
625
675
  @example
626
676
  var jqu = new Jqgrid_utils();
627
677
  col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
678
+ col_model = await jqu.add_link_details(col_model, host + '/html/table_size.html' , 'database','target="_blank"',{"database":"database","server":"server"});
628
679
  */
629
680
  async add_link_details(col_model, url, edit_field, attr = '', keys, format)
630
681
  {
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.4.8"
32
+ "version": "1.5.1"
33
33
  }