jqgrid_utils 1.9.1 → 1.21.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> ⏏
@@ -54,6 +55,7 @@ A module for Jqgrid_utils
54
55
  * [module.exports#put_json(url, data)](#exp_module_Jqgrid_utils--module.exports+put_json) ⇒ <code>object</code> ⏏
55
56
  * [module.exports#s_hide_del_icon()](#exp_module_Jqgrid_utils--module.exports+s_hide_del_icon) ⏏
56
57
  * [module.exports#hide_del_icon()](#exp_module_Jqgrid_utils--module.exports+hide_del_icon) ⏏
58
+ * [module.exports#add_link_details_csv(col_model, url, edit_field, attr, keys, format, seperator)](#exp_module_Jqgrid_utils--module.exports+add_link_details_csv) ⏏
57
59
  * [module.exports#add_link_details(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details) ⏏
58
60
  * [module.exports#add_link_details_separator(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details_separator) ⏏
59
61
  * [module.exports#add_link_separator(col_model, url, edit_field, fields)](#exp_module_Jqgrid_utils--module.exports+add_link_separator) ⏏
@@ -63,6 +65,27 @@ A module for Jqgrid_utils
63
65
  * [module.exports#set_filter(grid, data, fx, append_to)](#exp_module_Jqgrid_utils--module.exports+set_filter) ⏏
64
66
  * [module.exports#_filter()](#exp_module_Jqgrid_utils--module.exports+_filter) ⏏
65
67
 
68
+ <a name="exp_module_Jqgrid_utils--module.exports+append_seperator_link_column"></a>
69
+
70
+ ### module.exports#append\_seperator\_link\_column(col_model, url, field_value, base, attr, keys) ⏏
71
+ Append and sperator based link column to the end of a row
72
+
73
+ **Kind**: Exported function
74
+
75
+ | Param | Type | Description |
76
+ | --- | --- | --- |
77
+ | col_model | <code>object</code> | col_model of the grid |
78
+ | url | <code>string</code> | URL string |
79
+ | field_value | <code>string</code> | field value - the visible text of the anchor |
80
+ | base | <code>object</code> | base row key value - like {"name":'wiki','label':"Wiki"} |
81
+ | attr | <code>string</code> | URL Attributes |
82
+ | keys | <code>object</code> | keys and fields value to use |
83
+
84
+ **Example**
85
+ ```js
86
+ var jqu = new Jqgrid_utils();
87
+ 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"});
88
+ ```
66
89
  <a name="exp_module_Jqgrid_utils--module.exports+add_edit"></a>
67
90
 
68
91
  ### module.exports#add\_edit(col_model) ⏏
@@ -563,6 +586,28 @@ Hide the del iconf rom the grid
563
586
  var jqu = new Jqgrid_utils();
564
587
  await jqu.hide_del_icon();
565
588
  ```
589
+ <a name="exp_module_Jqgrid_utils--module.exports+add_link_details_csv"></a>
590
+
591
+ ### module.exports#add\_link\_details\_csv(col_model, url, edit_field, attr, keys, format, seperator) ⏏
592
+ Convert a cell into a link/url with data from another cell and spit the value by comma - CSV
593
+
594
+ **Kind**: Exported function
595
+
596
+ | Param | Type | Default | Description |
597
+ | --- | --- | --- | --- |
598
+ | col_model | <code>object</code> | | col_model of the grid |
599
+ | url | <code>string</code> | | URL string |
600
+ | edit_field | <code>string</code> | | Column/Cell to use |
601
+ | attr | <code>string</code> | | URL Attributes |
602
+ | keys | <code>object</code> | | keys and fields value to use |
603
+ | format | <code>object</code> | | format info |
604
+ | seperator | <code>string</code> | <code>&quot;,&quot;</code> | seperator of the cell value to split (default is comma) |
605
+
606
+ **Example**
607
+ ```js
608
+ var jqu = new Jqgrid_utils();
609
+ col_model = await jqu.add_link_details_csv(col_model, host + '/html/report.html' , 'tags','target="_blank"',{"tags":"tags"},',');
610
+ ```
566
611
  <a name="exp_module_Jqgrid_utils--module.exports+add_link_details"></a>
567
612
 
568
613
  ### module.exports#add\_link\_details(col_model, url, edit_field, attr, keys) ⏏
@@ -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
@@ -805,6 +872,99 @@ async hide_del_icon()
805
872
  }
806
873
 
807
874
 
875
+ /**
876
+ * Convert a cell into a link/url with data from another cell and spit the value by comma - CSV
877
+ @alias module:Jqgrid_utils
878
+ @param {object} - col_model of the grid
879
+ @param {string} - URL string
880
+ @param {string} - Column/Cell to use
881
+ @param {string} - URL Attributes
882
+ @param {object} - keys and fields value to use
883
+ @param {object} - format info
884
+ @param {string} - seperator of the cell value to split (default is comma)
885
+ @example
886
+ var jqu = new Jqgrid_utils();
887
+ col_model = await jqu.add_link_details_csv(col_model, host + '/html/report.html' , 'tags','target="_blank"',{"tags":"tags"},',');
888
+
889
+ */
890
+ async add_link_details_csv(col_model, url, edit_field, attr = '', keys, format, seperator=',')
891
+ {
892
+ let self = this;
893
+ if (url.indexOf('?') > -1)
894
+ {
895
+ url = url + '&';
896
+ }
897
+ else
898
+ {
899
+ url = url + '?';
900
+ }
901
+
902
+ for (let i = 0; i < col_model.length; i++)
903
+ {
904
+ if (col_model[i]['name'] === edit_field)
905
+ {
906
+ col_model[i]['formatter'] = function(cell_val, obj)
907
+ {
908
+ let key_val = cell_val;
909
+ const _cell_val = self.__cell_format(cell_val, format);
910
+ const a = _cell_val.split(seperator);
911
+ let cell_value = '';
912
+ for(let x in a)
913
+ {
914
+ const x_value = a[x].trim();
915
+ if(x_value)
916
+ {
917
+ if (typeof keys === 'object')
918
+ {
919
+ let pref = '';
920
+ for (let ii in keys)
921
+ {
922
+ let key = ii;
923
+ let v = keys[ii];
924
+ key_val = obj.rowData[v];
925
+ if (key_val)
926
+ {
927
+ if (key.indexOf('=') !== -1)
928
+ {
929
+ pref = pref + '' + key + '' + encodeURIComponent(x_value) + '&';
930
+ }
931
+ else
932
+ {
933
+ pref = pref + '' + key + '=' + encodeURIComponent(x_value) + '&';
934
+ }
935
+ }
936
+ }
937
+ if (pref.slice(-1) === '&')
938
+ {
939
+ pref = pref.slice(0, -1);
940
+ }
941
+ cell_value += '<a ' + attr + 'href="' + url + pref + '"> ' + x_value + '</a>' + seperator + ' ';
942
+ }
943
+ }
944
+ cell_val = cell_value.trim();
945
+ if(cell_val.slice(-1) === seperator) //remove last seperator
946
+ {
947
+ cell_val = cell_val.slice(0, -1);
948
+ }
949
+
950
+ }
951
+
952
+ if(cell_val)
953
+ {
954
+ return cell_val;
955
+ }
956
+ else
957
+ {
958
+ return _cell_val;
959
+ }
960
+ };
961
+ }
962
+
963
+ }
964
+
965
+ return col_model;
966
+ }
967
+
808
968
 
809
969
  /**
810
970
  * Convert a cell into a link/url with data from another cell
@@ -842,10 +1002,10 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
842
1002
  if (typeof keys === 'object')
843
1003
  {
844
1004
  let pref = '';
845
- for (i in keys)
1005
+ for (let ii in keys)
846
1006
  {
847
- let key = i;
848
- let v = keys[i];
1007
+ let key = ii;
1008
+ let v = keys[ii];
849
1009
  key_val = obj.rowData[v];
850
1010
  if (key_val)
851
1011
  {
@@ -896,6 +1056,7 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
896
1056
  return col_model;
897
1057
  }
898
1058
 
1059
+
899
1060
 
900
1061
  /**
901
1062
  * Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
@@ -925,11 +1086,11 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
925
1086
  if (typeof keys === 'object')
926
1087
  {
927
1088
  let pref = '';
928
- for (i in keys)
1089
+ for (let ii in keys)
929
1090
  {
930
1091
 
931
- let key = i;
932
- let v = keys[i];
1092
+ let key = ii;
1093
+ let v = keys[ii];
933
1094
  key_val = obj.rowData[v];
934
1095
  if (key_val)
935
1096
  {
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
@@ -804,6 +871,99 @@ async hide_del_icon()
804
871
  }
805
872
 
806
873
 
874
+ /**
875
+ * Convert a cell into a link/url with data from another cell and spit the value by comma - CSV
876
+ @alias module:Jqgrid_utils
877
+ @param {object} - col_model of the grid
878
+ @param {string} - URL string
879
+ @param {string} - Column/Cell to use
880
+ @param {string} - URL Attributes
881
+ @param {object} - keys and fields value to use
882
+ @param {object} - format info
883
+ @param {string} - seperator of the cell value to split (default is comma)
884
+ @example
885
+ var jqu = new Jqgrid_utils();
886
+ col_model = await jqu.add_link_details_csv(col_model, host + '/html/report.html' , 'tags','target="_blank"',{"tags":"tags"},',');
887
+
888
+ */
889
+ async add_link_details_csv(col_model, url, edit_field, attr = '', keys, format, seperator=',')
890
+ {
891
+ let self = this;
892
+ if (url.indexOf('?') > -1)
893
+ {
894
+ url = url + '&';
895
+ }
896
+ else
897
+ {
898
+ url = url + '?';
899
+ }
900
+
901
+ for (let i = 0; i < col_model.length; i++)
902
+ {
903
+ if (col_model[i]['name'] === edit_field)
904
+ {
905
+ col_model[i]['formatter'] = function(cell_val, obj)
906
+ {
907
+ let key_val = cell_val;
908
+ const _cell_val = self.__cell_format(cell_val, format);
909
+ const a = _cell_val.split(seperator);
910
+ let cell_value = '';
911
+ for(let x in a)
912
+ {
913
+ const x_value = a[x].trim();
914
+ if(x_value)
915
+ {
916
+ if (typeof keys === 'object')
917
+ {
918
+ let pref = '';
919
+ for (let ii in keys)
920
+ {
921
+ let key = ii;
922
+ let v = keys[ii];
923
+ key_val = obj.rowData[v];
924
+ if (key_val)
925
+ {
926
+ if (key.indexOf('=') !== -1)
927
+ {
928
+ pref = pref + '' + key + '' + encodeURIComponent(x_value) + '&';
929
+ }
930
+ else
931
+ {
932
+ pref = pref + '' + key + '=' + encodeURIComponent(x_value) + '&';
933
+ }
934
+ }
935
+ }
936
+ if (pref.slice(-1) === '&')
937
+ {
938
+ pref = pref.slice(0, -1);
939
+ }
940
+ cell_value += '<a ' + attr + 'href="' + url + pref + '"> ' + x_value + '</a>' + seperator + ' ';
941
+ }
942
+ }
943
+ cell_val = cell_value.trim();
944
+ if(cell_val.slice(-1) === seperator) //remove last seperator
945
+ {
946
+ cell_val = cell_val.slice(0, -1);
947
+ }
948
+
949
+ }
950
+
951
+ if(cell_val)
952
+ {
953
+ return cell_val;
954
+ }
955
+ else
956
+ {
957
+ return _cell_val;
958
+ }
959
+ };
960
+ }
961
+
962
+ }
963
+
964
+ return col_model;
965
+ }
966
+
807
967
 
808
968
  /**
809
969
  * Convert a cell into a link/url with data from another cell
@@ -841,10 +1001,10 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
841
1001
  if (typeof keys === 'object')
842
1002
  {
843
1003
  let pref = '';
844
- for (i in keys)
1004
+ for (let ii in keys)
845
1005
  {
846
- let key = i;
847
- let v = keys[i];
1006
+ let key = ii;
1007
+ let v = keys[ii];
848
1008
  key_val = obj.rowData[v];
849
1009
  if (key_val)
850
1010
  {
@@ -895,6 +1055,7 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
895
1055
  return col_model;
896
1056
  }
897
1057
 
1058
+
898
1059
 
899
1060
  /**
900
1061
  * Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
@@ -924,11 +1085,11 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
924
1085
  if (typeof keys === 'object')
925
1086
  {
926
1087
  let pref = '';
927
- for (i in keys)
1088
+ for (let ii in keys)
928
1089
  {
929
1090
 
930
- let key = i;
931
- let v = keys[i];
1091
+ let key = ii;
1092
+ let v = keys[ii];
932
1093
  key_val = obj.rowData[v];
933
1094
  if (key_val)
934
1095
  {
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.21.0"
33
33
  }