jqgrid_utils 1.4.9 → 1.5.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 +27 -0
- package/dist/jqgrid_utils.js +52 -0
- package/jqgrid_utils.js +52 -0
- package/package.json +1 -1
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
|
|
package/dist/jqgrid_utils.js
CHANGED
|
@@ -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
|
|
@@ -67,6 +117,7 @@ console.log(_data);
|
|
|
67
117
|
{
|
|
68
118
|
col_model[i]['formatter'] = function (cell_value, o)
|
|
69
119
|
{
|
|
120
|
+
cell_value = cell_value.toString();
|
|
70
121
|
let value = cell_value;
|
|
71
122
|
if(cell_value.length >= 8 && cell_value.indexOf(seperator) === -1)
|
|
72
123
|
{
|
|
@@ -626,6 +677,7 @@ async hide_del_icon()
|
|
|
626
677
|
@example
|
|
627
678
|
var jqu = new Jqgrid_utils();
|
|
628
679
|
col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
|
|
680
|
+
col_model = await jqu.add_link_details(col_model, host + '/html/table_size.html' , 'database','target="_blank"',{"database":"database","server":"server"});
|
|
629
681
|
*/
|
|
630
682
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
631
683
|
{
|
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
|
|
@@ -66,6 +116,7 @@ console.log(_data);
|
|
|
66
116
|
{
|
|
67
117
|
col_model[i]['formatter'] = function (cell_value, o)
|
|
68
118
|
{
|
|
119
|
+
cell_value = cell_value.toString();
|
|
69
120
|
let value = cell_value;
|
|
70
121
|
if(cell_value.length >= 8 && cell_value.indexOf(seperator) === -1)
|
|
71
122
|
{
|
|
@@ -625,6 +676,7 @@ async hide_del_icon()
|
|
|
625
676
|
@example
|
|
626
677
|
var jqu = new Jqgrid_utils();
|
|
627
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"});
|
|
628
680
|
*/
|
|
629
681
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
630
682
|
{
|
package/package.json
CHANGED