jqgrid_utils 1.1.5 → 1.1.8
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/dist/jqgrid_utils.js +56 -23
- package/jqgrid_utils.js +56 -23
- package/package.json +1 -1
package/dist/jqgrid_utils.js
CHANGED
|
@@ -230,11 +230,10 @@ async hide_del_icon()
|
|
|
230
230
|
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
// example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
|
|
235
234
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
236
235
|
{
|
|
237
|
-
|
|
236
|
+
let self = this;
|
|
238
237
|
if (url.indexOf('?') > -1)
|
|
239
238
|
{
|
|
240
239
|
url = url + '&';
|
|
@@ -281,21 +280,10 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
281
280
|
{
|
|
282
281
|
pref = pref.slice(0, -1);
|
|
283
282
|
}
|
|
284
|
-
if (format == 'format_ok')
|
|
285
|
-
{
|
|
286
|
-
|
|
287
|
-
if (cell_val == 0 || cell_val === 'fail')
|
|
288
|
-
{
|
|
289
|
-
cell_val = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
|
|
290
|
-
}
|
|
291
|
-
else
|
|
292
|
-
{
|
|
293
|
-
cell_val = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
283
|
|
|
284
|
+
const _cell_val = self.__cell_format(cell_val, format);
|
|
297
285
|
|
|
298
|
-
cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' +
|
|
286
|
+
cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
|
|
299
287
|
}
|
|
300
288
|
|
|
301
289
|
}
|
|
@@ -311,12 +299,11 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
311
299
|
|
|
312
300
|
|
|
313
301
|
|
|
314
|
-
|
|
302
|
+
// examplecol_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
|
|
303
|
+
async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
|
|
315
304
|
{
|
|
316
|
-
|
|
317
305
|
url = url + '/';
|
|
318
|
-
|
|
319
|
-
|
|
306
|
+
let self = this;
|
|
320
307
|
for (let i = 0; i < col_model.length; i++)
|
|
321
308
|
{
|
|
322
309
|
if (col_model[i]['name'] === edit_field)
|
|
@@ -330,6 +317,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
|
|
|
330
317
|
let pref = '';
|
|
331
318
|
for (i in keys)
|
|
332
319
|
{
|
|
320
|
+
|
|
333
321
|
let key = i;
|
|
334
322
|
let v = keys[i];
|
|
335
323
|
key_val = obj.rowData[v];
|
|
@@ -337,7 +325,14 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
|
|
|
337
325
|
{
|
|
338
326
|
if (key_val)
|
|
339
327
|
{
|
|
340
|
-
|
|
328
|
+
if(key != '')
|
|
329
|
+
{
|
|
330
|
+
pref += key + '' + '/' + encodeURIComponent(key_val);
|
|
331
|
+
}
|
|
332
|
+
else
|
|
333
|
+
{
|
|
334
|
+
pref += encodeURIComponent(key_val);
|
|
335
|
+
}
|
|
341
336
|
}
|
|
342
337
|
}
|
|
343
338
|
}
|
|
@@ -347,8 +342,8 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
|
|
|
347
342
|
{
|
|
348
343
|
pref = pref.slice(0, -1);
|
|
349
344
|
}
|
|
350
|
-
|
|
351
|
-
cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' +
|
|
345
|
+
const _cell_val = self.__cell_format(cell_val, format);
|
|
346
|
+
cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
|
|
352
347
|
}
|
|
353
348
|
|
|
354
349
|
}
|
|
@@ -368,9 +363,47 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
|
|
|
368
363
|
|
|
369
364
|
|
|
370
365
|
|
|
366
|
+
__cell_format(cell_value, format)
|
|
367
|
+
{
|
|
368
|
+
if (format == 'format_ok')
|
|
369
|
+
{
|
|
370
|
+
if (cell_value == 0 || cell_value === 'fail')
|
|
371
|
+
{
|
|
372
|
+
cell_value = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
|
|
373
|
+
}
|
|
374
|
+
else
|
|
375
|
+
{
|
|
376
|
+
cell_value = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return cell_value;
|
|
380
|
+
}
|
|
381
|
+
|
|
371
382
|
|
|
372
383
|
|
|
373
384
|
|
|
385
|
+
// let data_url = api + '/style_row?f=data&style=';
|
|
386
|
+
// let col_model_url = api + '/style_row?f=col_model';
|
|
387
|
+
// await jqu.subgrid(_id, id, data_url, col_model_url);
|
|
388
|
+
async subgrid(_id, id, data_url, col_model_url)
|
|
389
|
+
{
|
|
390
|
+
let col_model = JSON.parse(await aget_api(col_model_url));
|
|
391
|
+
let url = data_url + id;
|
|
392
|
+
let $s1 = jQuery("<table id='" + _id + "_t'></table>");
|
|
393
|
+
let data = jQuery(this).getLocalRow(id);
|
|
394
|
+
$s1.appendTo("#" + jQuery.jgrid.jqID(_id));
|
|
395
|
+
$s1.jqGrid({
|
|
396
|
+
colModel: col_model,
|
|
397
|
+
datatype: "json",
|
|
398
|
+
url: url,
|
|
399
|
+
gridview: true,
|
|
400
|
+
rownumbers: true,
|
|
401
|
+
autoencode: true,
|
|
402
|
+
sortname: "c1",
|
|
403
|
+
sortorder: "desc",
|
|
404
|
+
caption: data.name
|
|
405
|
+
});
|
|
406
|
+
}
|
|
374
407
|
|
|
375
408
|
|
|
376
409
|
|
package/jqgrid_utils.js
CHANGED
|
@@ -229,11 +229,10 @@ async hide_del_icon()
|
|
|
229
229
|
|
|
230
230
|
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
// example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
|
|
234
233
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
235
234
|
{
|
|
236
|
-
|
|
235
|
+
let self = this;
|
|
237
236
|
if (url.indexOf('?') > -1)
|
|
238
237
|
{
|
|
239
238
|
url = url + '&';
|
|
@@ -280,21 +279,10 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
280
279
|
{
|
|
281
280
|
pref = pref.slice(0, -1);
|
|
282
281
|
}
|
|
283
|
-
if (format == 'format_ok')
|
|
284
|
-
{
|
|
285
|
-
|
|
286
|
-
if (cell_val == 0 || cell_val === 'fail')
|
|
287
|
-
{
|
|
288
|
-
cell_val = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
|
|
289
|
-
}
|
|
290
|
-
else
|
|
291
|
-
{
|
|
292
|
-
cell_val = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
282
|
|
|
283
|
+
const _cell_val = self.__cell_format(cell_val, format);
|
|
296
284
|
|
|
297
|
-
cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' +
|
|
285
|
+
cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
|
|
298
286
|
}
|
|
299
287
|
|
|
300
288
|
}
|
|
@@ -310,12 +298,11 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
310
298
|
|
|
311
299
|
|
|
312
300
|
|
|
313
|
-
|
|
301
|
+
// examplecol_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
|
|
302
|
+
async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
|
|
314
303
|
{
|
|
315
|
-
|
|
316
304
|
url = url + '/';
|
|
317
|
-
|
|
318
|
-
|
|
305
|
+
let self = this;
|
|
319
306
|
for (let i = 0; i < col_model.length; i++)
|
|
320
307
|
{
|
|
321
308
|
if (col_model[i]['name'] === edit_field)
|
|
@@ -329,6 +316,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
|
|
|
329
316
|
let pref = '';
|
|
330
317
|
for (i in keys)
|
|
331
318
|
{
|
|
319
|
+
|
|
332
320
|
let key = i;
|
|
333
321
|
let v = keys[i];
|
|
334
322
|
key_val = obj.rowData[v];
|
|
@@ -336,7 +324,14 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
|
|
|
336
324
|
{
|
|
337
325
|
if (key_val)
|
|
338
326
|
{
|
|
339
|
-
|
|
327
|
+
if(key != '')
|
|
328
|
+
{
|
|
329
|
+
pref += key + '' + '/' + encodeURIComponent(key_val);
|
|
330
|
+
}
|
|
331
|
+
else
|
|
332
|
+
{
|
|
333
|
+
pref += encodeURIComponent(key_val);
|
|
334
|
+
}
|
|
340
335
|
}
|
|
341
336
|
}
|
|
342
337
|
}
|
|
@@ -346,8 +341,8 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
|
|
|
346
341
|
{
|
|
347
342
|
pref = pref.slice(0, -1);
|
|
348
343
|
}
|
|
349
|
-
|
|
350
|
-
cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' +
|
|
344
|
+
const _cell_val = self.__cell_format(cell_val, format);
|
|
345
|
+
cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + _cell_val + '</a>';
|
|
351
346
|
}
|
|
352
347
|
|
|
353
348
|
}
|
|
@@ -367,9 +362,47 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
|
|
|
367
362
|
|
|
368
363
|
|
|
369
364
|
|
|
365
|
+
__cell_format(cell_value, format)
|
|
366
|
+
{
|
|
367
|
+
if (format == 'format_ok')
|
|
368
|
+
{
|
|
369
|
+
if (cell_value == 0 || cell_value === 'fail')
|
|
370
|
+
{
|
|
371
|
+
cell_value = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
|
|
372
|
+
}
|
|
373
|
+
else
|
|
374
|
+
{
|
|
375
|
+
cell_value = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return cell_value;
|
|
379
|
+
}
|
|
380
|
+
|
|
370
381
|
|
|
371
382
|
|
|
372
383
|
|
|
384
|
+
// let data_url = api + '/style_row?f=data&style=';
|
|
385
|
+
// let col_model_url = api + '/style_row?f=col_model';
|
|
386
|
+
// await jqu.subgrid(_id, id, data_url, col_model_url);
|
|
387
|
+
async subgrid(_id, id, data_url, col_model_url)
|
|
388
|
+
{
|
|
389
|
+
let col_model = JSON.parse(await aget_api(col_model_url));
|
|
390
|
+
let url = data_url + id;
|
|
391
|
+
let $s1 = jQuery("<table id='" + _id + "_t'></table>");
|
|
392
|
+
let data = jQuery(this).getLocalRow(id);
|
|
393
|
+
$s1.appendTo("#" + jQuery.jgrid.jqID(_id));
|
|
394
|
+
$s1.jqGrid({
|
|
395
|
+
colModel: col_model,
|
|
396
|
+
datatype: "json",
|
|
397
|
+
url: url,
|
|
398
|
+
gridview: true,
|
|
399
|
+
rownumbers: true,
|
|
400
|
+
autoencode: true,
|
|
401
|
+
sortname: "c1",
|
|
402
|
+
sortorder: "desc",
|
|
403
|
+
caption: data.name
|
|
404
|
+
});
|
|
405
|
+
}
|
|
373
406
|
|
|
374
407
|
|
|
375
408
|
|
package/package.json
CHANGED