jqgrid_utils 1.9.1 → 1.20.0

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#append_seperator_link_column(col_model, url, field_value, base, attr, keys)](#exp_module_Jqgrid_utils--module.exports+append_seperator_link_column) ⏏
30
31
  * [module.exports#add_edit(col_model)](#exp_module_Jqgrid_utils--module.exports+add_edit) ⏏
31
32
  * [module.exports#add_textarea(col_model, edit_field)](#exp_module_Jqgrid_utils--module.exports+add_textarea) ⏏
32
33
  * [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> ⏏
@@ -63,6 +64,27 @@ A module for Jqgrid_utils
63
64
  * [module.exports#set_filter(grid, data, fx, append_to)](#exp_module_Jqgrid_utils--module.exports+set_filter) ⏏
64
65
  * [module.exports#_filter()](#exp_module_Jqgrid_utils--module.exports+_filter) ⏏
65
66
 
67
+ <a name="exp_module_Jqgrid_utils--module.exports+append_seperator_link_column"></a>
68
+
69
+ ### module.exports#append\_seperator\_link\_column(col_model, url, field_value, base, attr, keys) ⏏
70
+ Append and sperator based link column to the end of a row
71
+
72
+ **Kind**: Exported function
73
+
74
+ | Param | Type | Description |
75
+ | --- | --- | --- |
76
+ | col_model | <code>object</code> | col_model of the grid |
77
+ | url | <code>string</code> | URL string |
78
+ | field_value | <code>string</code> | field value - the visible text of the anchor |
79
+ | base | <code>object</code> | base row key value - like {"name":'wiki','label':"Wiki"} |
80
+ | attr | <code>string</code> | URL Attributes |
81
+ | keys | <code>object</code> | keys and fields value to use |
82
+
83
+ **Example**
84
+ ```js
85
+ var jqu = new Jqgrid_utils();
86
+ col_model = await jqu.append_seperator_link_column(col_model, 'http://wiki.foo.com/index.php' ,'Wiki',{"name":'wiki','label':"Wiki","width":"65px","align":"center"} ,'target="_blank"',{"report_central":"name"});
87
+ ```
66
88
  <a name="exp_module_Jqgrid_utils--module.exports+add_edit"></a>
67
89
 
68
90
  ### module.exports#add\_edit(col_model) ⏏
@@ -22,6 +22,73 @@ module.exports = class Vanilla_website_utils
22
22
 
23
23
  }
24
24
 
25
+
26
+
27
+ /**
28
+ *Append and sperator based link column to the end of a row
29
+ @alias module:Jqgrid_utils
30
+ @param {object} - col_model of the grid
31
+ @param {string} - URL string
32
+ @param {string} - field value - the visible text of the anchor
33
+ @param {object} - base row key value - like {"name":'wiki','label':"Wiki"}
34
+ @param {string} - URL Attributes
35
+ @param {object} - keys and fields value to use
36
+ @example
37
+ var jqu = new Jqgrid_utils();
38
+ col_model = await jqu.append_seperator_link_column(col_model, 'http://wiki.foo.com/index.php' ,'Wiki',{"name":'wiki','label':"Wiki","width":"65px","align":"center"} ,'target="_blank"',{"report_central":"name"});
39
+
40
+ */
41
+
42
+ async append_seperator_link_column(col_model, url, field_value, base, attr = '', keys)
43
+ {
44
+ url = url + '/';
45
+ let self = this;
46
+ base['formatter'] = function(cell_val, obj)
47
+ {
48
+ let _cell_val = field_value;
49
+ if (typeof keys === 'object')
50
+ {
51
+ let pref = '';
52
+ for (let i in keys)
53
+ {
54
+
55
+ let key = i;
56
+ let v = keys[i];
57
+ let key_val = obj.rowData[v];
58
+ if (key_val)
59
+ {
60
+ if (key_val)
61
+ {
62
+ if(key != '')
63
+ {
64
+ pref += key + '' + '/' + encodeURIComponent(key_val) + '/';
65
+ }
66
+ else
67
+ {
68
+ pref += encodeURIComponent(key_val);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ if (pref)
74
+ {
75
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
76
+ {
77
+ pref = pref.slice(0, -1);
78
+ }
79
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
80
+ }
81
+
82
+ }
83
+
84
+ return cell_val;
85
+ }
86
+
87
+ col_model.push(base);
88
+
89
+ return col_model;
90
+ }
91
+
25
92
 
26
93
  /**
27
94
  * add textarea
@@ -842,10 +909,10 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
842
909
  if (typeof keys === 'object')
843
910
  {
844
911
  let pref = '';
845
- for (i in keys)
912
+ for (let ii in keys)
846
913
  {
847
- let key = i;
848
- let v = keys[i];
914
+ let key = ii;
915
+ let v = keys[ii];
849
916
  key_val = obj.rowData[v];
850
917
  if (key_val)
851
918
  {
@@ -896,6 +963,7 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
896
963
  return col_model;
897
964
  }
898
965
 
966
+
899
967
 
900
968
  /**
901
969
  * Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
@@ -925,11 +993,11 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
925
993
  if (typeof keys === 'object')
926
994
  {
927
995
  let pref = '';
928
- for (i in keys)
996
+ for (let ii in keys)
929
997
  {
930
998
 
931
- let key = i;
932
- let v = keys[i];
999
+ let key = ii;
1000
+ let v = keys[ii];
933
1001
  key_val = obj.rowData[v];
934
1002
  if (key_val)
935
1003
  {
package/jqgrid_utils.js CHANGED
@@ -21,6 +21,73 @@ module.exports = class Vanilla_website_utils
21
21
 
22
22
  }
23
23
 
24
+
25
+
26
+ /**
27
+ *Append and sperator based link column to the end of a row
28
+ @alias module:Jqgrid_utils
29
+ @param {object} - col_model of the grid
30
+ @param {string} - URL string
31
+ @param {string} - field value - the visible text of the anchor
32
+ @param {object} - base row key value - like {"name":'wiki','label':"Wiki"}
33
+ @param {string} - URL Attributes
34
+ @param {object} - keys and fields value to use
35
+ @example
36
+ var jqu = new Jqgrid_utils();
37
+ col_model = await jqu.append_seperator_link_column(col_model, 'http://wiki.foo.com/index.php' ,'Wiki',{"name":'wiki','label':"Wiki","width":"65px","align":"center"} ,'target="_blank"',{"report_central":"name"});
38
+
39
+ */
40
+
41
+ async append_seperator_link_column(col_model, url, field_value, base, attr = '', keys)
42
+ {
43
+ url = url + '/';
44
+ let self = this;
45
+ base['formatter'] = function(cell_val, obj)
46
+ {
47
+ let _cell_val = field_value;
48
+ if (typeof keys === 'object')
49
+ {
50
+ let pref = '';
51
+ for (let i in keys)
52
+ {
53
+
54
+ let key = i;
55
+ let v = keys[i];
56
+ let key_val = obj.rowData[v];
57
+ if (key_val)
58
+ {
59
+ if (key_val)
60
+ {
61
+ if(key != '')
62
+ {
63
+ pref += key + '' + '/' + encodeURIComponent(key_val) + '/';
64
+ }
65
+ else
66
+ {
67
+ pref += encodeURIComponent(key_val);
68
+ }
69
+ }
70
+ }
71
+ }
72
+ if (pref)
73
+ {
74
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
75
+ {
76
+ pref = pref.slice(0, -1);
77
+ }
78
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
79
+ }
80
+
81
+ }
82
+
83
+ return cell_val;
84
+ }
85
+
86
+ col_model.push(base);
87
+
88
+ return col_model;
89
+ }
90
+
24
91
 
25
92
  /**
26
93
  * add textarea
@@ -841,10 +908,10 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
841
908
  if (typeof keys === 'object')
842
909
  {
843
910
  let pref = '';
844
- for (i in keys)
911
+ for (let ii in keys)
845
912
  {
846
- let key = i;
847
- let v = keys[i];
913
+ let key = ii;
914
+ let v = keys[ii];
848
915
  key_val = obj.rowData[v];
849
916
  if (key_val)
850
917
  {
@@ -895,6 +962,7 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
895
962
  return col_model;
896
963
  }
897
964
 
965
+
898
966
 
899
967
  /**
900
968
  * Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
@@ -924,11 +992,11 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
924
992
  if (typeof keys === 'object')
925
993
  {
926
994
  let pref = '';
927
- for (i in keys)
995
+ for (let ii in keys)
928
996
  {
929
997
 
930
- let key = i;
931
- let v = keys[i];
998
+ let key = ii;
999
+ let v = keys[ii];
932
1000
  key_val = obj.rowData[v];
933
1001
  if (key_val)
934
1002
  {
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.9.1"
32
+ "version": "1.20.0"
33
33
  }