jqgrid_utils 1.20.0 → 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
@@ -55,6 +55,7 @@ A module for Jqgrid_utils
55
55
  * [module.exports#put_json(url, data)](#exp_module_Jqgrid_utils--module.exports+put_json) ⇒ <code>object</code> ⏏
56
56
  * [module.exports#s_hide_del_icon()](#exp_module_Jqgrid_utils--module.exports+s_hide_del_icon) ⏏
57
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) ⏏
58
59
  * [module.exports#add_link_details(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details) ⏏
59
60
  * [module.exports#add_link_details_separator(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details_separator) ⏏
60
61
  * [module.exports#add_link_separator(col_model, url, edit_field, fields)](#exp_module_Jqgrid_utils--module.exports+add_link_separator) ⏏
@@ -585,6 +586,28 @@ Hide the del iconf rom the grid
585
586
  var jqu = new Jqgrid_utils();
586
587
  await jqu.hide_del_icon();
587
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
+ ```
588
611
  <a name="exp_module_Jqgrid_utils--module.exports+add_link_details"></a>
589
612
 
590
613
  ### module.exports#add\_link\_details(col_model, url, edit_field, attr, keys) ⏏
@@ -872,6 +872,99 @@ async hide_del_icon()
872
872
  }
873
873
 
874
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
+
875
968
 
876
969
  /**
877
970
  * Convert a cell into a link/url with data from another cell
package/jqgrid_utils.js CHANGED
@@ -871,6 +871,99 @@ async hide_del_icon()
871
871
  }
872
872
 
873
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
+
874
967
 
875
968
  /**
876
969
  * Convert a cell into a link/url with data from another cell
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.20.0"
32
+ "version": "1.21.0"
33
33
  }