jqgrid_utils 1.25.1 → 1.26.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.
@@ -683,18 +683,39 @@ console.log(_data);
683
683
 
684
684
 
685
685
  /**
686
- * Hide a col_model column before load the grid
686
+ * Hide all columns execpt column
687
687
  * @alias module:Jqgrid_utils
688
688
  * @param {object} - col_model of the grid
689
- * @param {string} - name of the column to hide
689
+ * @param {array} - array of names to not to hide
690
690
  * @returns {object} col_model
691
691
  * @example
692
- if(filter['_filter'] == 'ch_p_higher_ch_plus_10pc')
692
+ col_model = await jqu.hide_all_columns_except(col_model,['supplier','customer']);
693
+ */
694
+ async hide_all_columns_except(col_model,fields)
695
+ {
696
+ for(let i=0;i< col_model.length;i++)
693
697
  {
694
- col_model = await jqu.hide_column(col_model,'wholesale');
695
- col_model = await jqu.hide_column(col_model,'wholesale_formula');
698
+ if( fields.indexOf(col_model[i]['name']) > -1)
699
+ {
700
+ col_model[i]['hidden'] = false;
701
+ }
702
+ else
703
+ {
704
+ col_model[i]['hidden'] = true;
705
+ }
696
706
  }
707
+ return col_model;
708
+ }
697
709
 
710
+ /**
711
+ * Hide a col_model column before load the grid
712
+ * @alias module:Jqgrid_utils
713
+ * @param {object} - col_model of the grid
714
+ * @param {string} - name of the column to hide
715
+ * @returns {object} col_model
716
+ * @example
717
+ col_model = await jqu.hide_column(col_model,'wholesale');
718
+ col_model = await jqu.hide_column(col_model,'wholesale_formula');
698
719
  */
699
720
  async hide_column(col_model,field)
700
721
  {
@@ -1230,7 +1251,7 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
1230
1251
  col_model[i]['formatter'] = function(cell_val, obj)
1231
1252
  {
1232
1253
  let key_val = cell_val;
1233
-
1254
+ const t = cell_val.toString();
1234
1255
  if (typeof keys === 'object')
1235
1256
  {
1236
1257
  let pref = '';
@@ -1261,18 +1282,19 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
1261
1282
  pref = pref.slice(0, -1);
1262
1283
  }
1263
1284
  const _cell_val = self.__cell_format(cell_val, format);
1264
- if(cell_val)
1285
+ if(t !='')
1265
1286
  {
1266
1287
  cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
1267
1288
  }
1268
1289
  else
1269
1290
  {
1291
+
1270
1292
  cell_val = '';
1271
1293
  }
1272
1294
  }
1273
1295
 
1274
1296
  }
1275
- if(cell_val)
1297
+ if(t)
1276
1298
  {
1277
1299
  return cell_val;
1278
1300
  }
package/jqgrid_utils.js CHANGED
@@ -682,18 +682,39 @@ console.log(_data);
682
682
 
683
683
 
684
684
  /**
685
- * Hide a col_model column before load the grid
685
+ * Hide all columns execpt column
686
686
  * @alias module:Jqgrid_utils
687
687
  * @param {object} - col_model of the grid
688
- * @param {string} - name of the column to hide
688
+ * @param {array} - array of names to not to hide
689
689
  * @returns {object} col_model
690
690
  * @example
691
- if(filter['_filter'] == 'ch_p_higher_ch_plus_10pc')
691
+ col_model = await jqu.hide_all_columns_except(col_model,['supplier','customer']);
692
+ */
693
+ async hide_all_columns_except(col_model,fields)
694
+ {
695
+ for(let i=0;i< col_model.length;i++)
692
696
  {
693
- col_model = await jqu.hide_column(col_model,'wholesale');
694
- col_model = await jqu.hide_column(col_model,'wholesale_formula');
697
+ if( fields.indexOf(col_model[i]['name']) > -1)
698
+ {
699
+ col_model[i]['hidden'] = false;
700
+ }
701
+ else
702
+ {
703
+ col_model[i]['hidden'] = true;
704
+ }
695
705
  }
706
+ return col_model;
707
+ }
696
708
 
709
+ /**
710
+ * Hide a col_model column before load the grid
711
+ * @alias module:Jqgrid_utils
712
+ * @param {object} - col_model of the grid
713
+ * @param {string} - name of the column to hide
714
+ * @returns {object} col_model
715
+ * @example
716
+ col_model = await jqu.hide_column(col_model,'wholesale');
717
+ col_model = await jqu.hide_column(col_model,'wholesale_formula');
697
718
  */
698
719
  async hide_column(col_model,field)
699
720
  {
@@ -1229,7 +1250,7 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
1229
1250
  col_model[i]['formatter'] = function(cell_val, obj)
1230
1251
  {
1231
1252
  let key_val = cell_val;
1232
-
1253
+ const t = cell_val.toString();
1233
1254
  if (typeof keys === 'object')
1234
1255
  {
1235
1256
  let pref = '';
@@ -1260,18 +1281,19 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
1260
1281
  pref = pref.slice(0, -1);
1261
1282
  }
1262
1283
  const _cell_val = self.__cell_format(cell_val, format);
1263
- if(cell_val)
1284
+ if(t !='')
1264
1285
  {
1265
1286
  cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
1266
1287
  }
1267
1288
  else
1268
1289
  {
1290
+
1269
1291
  cell_val = '';
1270
1292
  }
1271
1293
  }
1272
1294
 
1273
1295
  }
1274
- if(cell_val)
1296
+ if(t)
1275
1297
  {
1276
1298
  return cell_val;
1277
1299
  }
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.25.1"
32
+ "version": "1.26.1"
33
33
  }