Jqgrid_utils
Convenient Functions for free jqGrid
How to install:
npm install jqgrid_utils
Usage:
<script src="../node_modules/jqgrid_utils/dist/jqgrid_utils.js"></script>
Example:
let jqu = new Jqgrid_utils();
Source: https://w3.calantas.org/free-dockers/jqgrid_utils/
Jqgrid_utils
A module for Jqgrid_utils
-
Jqgrid_utils
-
module.exports#_date112_to_DMY(cell_value, seperator)
⏏ -
module.exports#date112_to_DMY(col_model, edit_field, seperator)
⏏ -
module.exports#add_ok_button(col_model, fields) ⇒
array
⏏ -
module.exports#get_filled_cell_table_data(_grid, fields) ⇒
array
⏏ -
module.exports#get_filled_cell_data(_grid, fields) ⇒
object
⏏ -
module.exports#set_link(col_model, edit_field, url) ⇒
object
⏏ -
module.exports#hide_column(col_model, field) ⇒
object
⏏ -
module.exports#s_grid_set_caption(_grid, data)
⏏ -
module.exports#grid_set_caption(_grid, data)
⏏ -
module.exports#s_resize_saved_cell_width(col_model, page, grid)
⏏ -
module.exports#resize_saved_cell_width(col_model, page, grid)
⏏ -
module.exports#resize_cell(the, column, not)
⏏ -
module.exports#upsert_row(row, url, req) ⇒
object
⏏ -
module.exports#insert_row(row, url) ⇒
object
⏏ -
module.exports#update_row(row, url, req) ⇒
object
⏏ -
module.exports#delete_row(_id, url) ⇒
object
⏏ -
module.exports#adelete_api(url, json) ⇒
object
⏏ -
module.exports#post_json(url, data) ⇒
object
⏏ -
module.exports#put_json(url, data) ⇒
object
⏏ -
module.exports#s_hide_del_icon()
⏏ -
module.exports#hide_del_icon()
⏏ -
module.exports#add_link_details(col_model, url, edit_field, attr, keys)
⏏ -
module.exports#add_link_details_separator(col_model, url, edit_field, attr, keys)
⏏ -
module.exports#add_link_separator(col_model, url, edit_field, fields)
⏏ -
module.exports#__cell_format()
⏏ -
module.exports#subgrid(_id, id, url, col_model, caption)
⏏ -
module.exports#add_image(col_model, edit_field, size, link)
⏏ -
module.exports#set_filter(grid, data, fx, append_to)
⏏ -
module.exports#_filter()
⏏
-
module.exports#_date112_to_DMY(cell_value, seperator)
⏏
module.exports#_date112_to_DMY(cell_value, seperator) Convert a 112 date string to a DMY format with sepertaor - sync function
Kind: Exported function
Param | Type | Default | Description |
---|---|---|---|
cell_value | string |
date string | |
seperator | string |
"/" |
seperator used |
Example
var jqu = new Jqgrid_utils();
let _data = jqu._date112_to_DMY('20220104','/');
console.log(_data);
⏏
module.exports#date112_to_DMY(col_model, edit_field, seperator) Convert a 112 date to a DMY format with sepertaor
Kind: Exported function
Param | Type | Default | Description |
---|---|---|---|
col_model | object |
col_model of the grid | |
edit_field | string |
name of the date 112 column what should get converted | |
seperator | string |
"/" |
seperator used |
Example
var jqu = new Jqgrid_utils();
let _data = await jqu.date112_to_DMY(this,'field','/');
console.log(_data);
array
⏏
module.exports#add_ok_button(col_model, fields) ⇒ Add an OK Button
Kind: Exported function
Returns: array
- - col_model
Param | Type | Description |
---|---|---|
col_model | array |
grid col_model |
fields | array |
list of columns names what will be converted to ok buttons |
Example
var jqu = new Jqgrid_utils();
col_model = await jqu.add_ok_button(col_model, ['checked']);
array
⏏
module.exports#get_filled_cell_table_data(_grid, fields) ⇒ Get the filled cell data
Kind: Exported function
Returns: array
- - table array
Param | Type | Description |
---|---|---|
_grid | object |
the grid object or its name |
fields | array |
list of columns names what will be collected |
Example
var jqu = new Jqgrid_utils();
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
object
⏏
module.exports#get_filled_cell_data(_grid, fields) ⇒ Get the filled cell data
Kind: Exported function
Returns: object
- - json object of the colleted fields
Param | Type | Description |
---|---|---|
_grid | object |
the grid object or its name |
fields | array |
list of columns names what will be collected |
Example
var jqu = new Jqgrid_utils();
col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
object
⏏
module.exports#set_link(col_model, edit_field, url) ⇒ Add an URL from the data to a specific cell/column
Kind: Exported function
Returns: object
- https://foo.bar.com/av0_code/bar
Param | Type | Description |
---|---|---|
col_model | object |
col_model of the grid |
edit_field | string |
name of the column what should get convert to the url |
url | string |
the used url of the data |
Example
var jqu = new Jqgrid_utils();
let _data = await jqu.get_filled_cell_data(this,["P-","bulk","wholesale"]);
console.log(_data);
object
⏏
module.exports#hide_column(col_model, field) ⇒ Hide a col_model column before load the grid
Kind: Exported function
Returns: object
- col_model
Param | Type | Description |
---|---|---|
col_model | object |
col_model of the grid |
field | string |
name of the column to hide |
Example
if(filter['_filter'] == 'ch_p_higher_ch_plus_10pc')
{
col_model = await jqu.hide_column(col_model,'wholesale');
col_model = await jqu.hide_column(col_model,'wholesale_formula');
}
⏏
module.exports#s_grid_set_caption(_grid, data) Kind: Exported function
Param | Type | Description |
---|---|---|
_grid | object |
gridobject; |
data | object |
grid data (optional); |
Example
var jqu = new Jqgrid_utils();
loadComplete: function(){
jqu.grid_set_caption(this);
},
⏏
module.exports#grid_set_caption(_grid, data) Adding the row count number to the caption
Kind: Exported function
Param | Type | Description |
---|---|---|
_grid | object |
gridobject; |
data | object |
grid data (optional); |
Example
var jqu = new Jqgrid_utils();
loadComplete: function(){
await jqu.grid_set_caption(this);
},
⏏
module.exports#s_resize_saved_cell_width(col_model, page, grid) Kind: Exported function
Param | Type | Default | Description |
---|---|---|---|
col_model | object |
the col_model of the grid | |
page | string |
false |
the name of the page(optional) |
grid | object |
false |
the grid objec(optional) |
Example
col_model = await jqu.resize_saved_cell_width(col_model);
⏏
module.exports#resize_saved_cell_width(col_model, page, grid) Kind: Exported function
Param | Type | Default | Description |
---|---|---|---|
col_model | object |
the col_model of the grid | |
page | string |
false |
the name of the page(optional) |
grid | object |
false |
the grid objec(optional) |
Example
col_model = await jqu.resize_saved_cell_width(col_model);
⏏
module.exports#resize_cell(the, column, not) Kind: Exported function
Param | Type | Description |
---|---|---|
the | string |
width of the resized column |
column | string |
number what get resized |
not | string |
in use yet |
Example
var jqu = new Jqgrid_utils({page:'mypage'});
resizeStop: jqu.resize_cell,
object
⏏
module.exports#upsert_row(row, url, req) ⇒ Upsert(insert or update) from the grid to an API
Kind: Exported function
Returns: object
- {update: 'ok'} or {update: 'failed'}
Param | Type | Description |
---|---|---|
row | object |
row object |
url | string |
url of the API |
req | string |
data oject |
Example
var jqu = new Jqgrid_utils();
afterSetRow: async function(row)
{
let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
console.log(r);
},
object
⏏
module.exports#insert_row(row, url) ⇒ Insert from the grid to an API used by the upsert_row function
Kind: Exported function
Returns: object
- Object from the the API like {update: 'ok'} or {update: 'failed'}
Param | Type | Description |
---|---|---|
row | object |
row object |
url | string |
URL of the API |
Example
var jqu = new Jqgrid_utils();
afterSetRow: async function(row)
{
let r = await jqu.insert_row(row, 'http://api.com');
console.log(r);
},
object
⏏
module.exports#update_row(row, url, req) ⇒ Update from the grid to an API used by the upsert_row function
Kind: Exported function
Returns: object
- Object from the the API like {update: 'ok'} or {update: 'failed'}
Param | Type | Description |
---|---|---|
row | object |
row object |
url | string |
url of the API |
req | string |
data oject |
Example
var jqu = new Jqgrid_utils();
afterSetRow: async function(row)
{
let r = await jqu.update_row(row, 'http://api.com',{'key':value});
console.log(r);
},
object
⏏
module.exports#delete_row(_id, url) ⇒ Delete from the grid to an API
Kind: Exported function
Returns: object
- @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
Param | Type | Description |
---|---|---|
_id | string |
row id |
url | string |
url of the API |
Example
var jqu = new Jqgrid_utils();
afterDelRow: async function(row)
{
const r = await jqu.delete_row('id', 'http://api.com');
console.log(r + ' : ' + row + ' - from API');
},
object
⏏
module.exports#adelete_api(url, json) ⇒ Async Delete request used by function delete_row
Kind: Exported function
Returns: object
- @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
Param | Type | Default | Description |
---|---|---|---|
url | string |
url of the API | |
json | boalan |
false |
header should be json type? default form type |
Example
var jqu = new Jqgrid_utils();
afterDelRow: async function(row)
{
ret = JSON.parse(await jqu.adelete_api(url));
},
object
⏏
module.exports#post_json(url, data) ⇒ Async Post request used by the update_row function
Kind: Exported function
Returns: object
- @returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
Param | Type | Description |
---|---|---|
url | string |
url of the API |
data | object |
json object |
Example
var jqu = new Jqgrid_utils();
ret = JSON.parse(await jqu.post_json(url,{'key':value,'key2':'value'}));
object
⏏
module.exports#put_json(url, data) ⇒ Async Put request used by the insert_row function
Kind: Exported function
Returns: object
- @returns {object} Object from the the API like {insert: 'ok'} or {insert: 'failed'}
Param | Type | Description |
---|---|---|
url | string |
url of the API |
data | object |
json object |
Example
var jqu = new Jqgrid_utils();
ret = JSON.parse(await jqu.put_json(url,{'key':value,'key2':'value2'}));
⏏
module.exports#s_hide_del_icon() Hide the del iconf rom the grid
Kind: Exported function
Example
var jqu = new Jqgrid_utils();
jqu.hide_del_icon();
⏏
module.exports#hide_del_icon() Hide the del iconf rom the grid
Kind: Exported function
Example
var jqu = new Jqgrid_utils();
await jqu.hide_del_icon();
⏏
module.exports#add_link_details(col_model, url, edit_field, attr, keys) Convert a cell into a link/url with data from another cell
Kind: Exported function
Param | Type | Description |
---|---|---|
col_model | object |
col_model of the grid |
url | string |
URL string |
edit_field | string |
Column/Cell to use |
attr | string |
URL Attributes |
keys | object |
keys and fields value to use |
Example
var jqu = new Jqgrid_utils();
col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
col_model = await jqu.add_link_details(col_model, host + '/html/table_size.html' , 'database','target="_blank"',{"database":"database","server":"server"});
⏏
module.exports#add_link_details_separator(col_model, url, edit_field, attr, keys) Convert a cell into seperated based link/url like https://foo.bar.com/field/value/field/value
Kind: Exported function
Param | Type | Description |
---|---|---|
col_model | object |
col_model of the grid |
url | string |
URL string |
edit_field | string |
Column/Cell to use |
attr | string |
URL Attributes |
keys | object |
keys and fields value to use |
Example
var jqu = new Jqgrid_utils();
col_model = await jqu.add_link_details_separator(col_model, url1 , 'style','target="_blank"',{"pricelist":"pricelist","style":"style"});
col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'target_column','target="_blank"',{"mykey":"myval"});
⏏
module.exports#add_link_separator(col_model, url, edit_field, fields) Convert a cell into seperated based link/url include parameter based url like https://foo.bar.com/field.html?k=v
Kind: Exported function
Param | Type | Description |
---|---|---|
col_model | object |
col_model of the grid |
url | string |
URL string |
edit_field | array |
array of dict |
fields | string |
URL Attributes |
Example
var jqu = new Jqgrid_utils();
col_model = await jqu.add_link_separator(col_model, host + '/html' , 'style',[
{
'field':'pricelist',
'extension':'.html',
'fields':{'style':'style'}
}
]);
⏏
module.exports#__cell_format() Private Function
⏏
module.exports#subgrid(_id, id, url, col_model, caption) Kind: Exported function
Param | Type | Description |
---|---|---|
_id | string |
row_id |
id | string |
data id |
url | string |
url to request |
col_model | object |
col_model for the table |
caption | string |
Add to the caption of the subgrid |
Example
subGrid: true,
,subGridRowExpanded: async function(_id, id) {
let data_url2 = api + '/process_locations?f=data&process=';
let col_model_url2 = api + '/process_locations?f=col_model';
let col_model2 = JSON.parse(await vwu.aget_api(col_model_url2));
await jqu.subgrid(_id, id, data_url2, col_model2,'Locations for Process');
let data_url = api + '/process_styles?f=data&process=';
let col_model_url = api + '/process_styles?f=col_model';
let col_model = JSON.parse(await vwu.aget_api(col_model_url));
await jqu.subgrid(_id, id, data_url, col_model,'Styles for Process');
},
or
subGrid: true,
subGridRowExpanded: async function(_id, id) {
let row_data = jQuery(this).jqGrid ('getRowData', id);
let param={f:'data','style':row_data['style'],pricelist:'P-TENENGR1'};
let data_url = api + '/order_ln';
data_url = await add_parameters(data_url, param);
let col_model_url2 = api + '/order_ln?f=col_model';
let col_model2 = JSON.parse(await vwu.aget_api(col_model_url2));
await jqu.subgrid(_id, false, data_url, col_model2,'Order Lines for ' + row_data['style']);
},
⏏
module.exports#add_image(col_model, edit_field, size, link) Kind: Exported function
Param | Type | Default | Description |
---|---|---|---|
col_model | object |
col_model for the grid | |
edit_field | string |
field what include the image/picture href path like http://mypicture.png | |
size | int |
size of the picture | |
link | bolen |
false |
image path should be a link |
Example
col_model = await jqu.add_image(col_model, 'image', 60, false);
⏏
module.exports#set_filter(grid, data, fx, append_to) Add a filter to the website beside the grid
Kind: Exported function
Param | Type | Default | Description |
---|---|---|---|
grid | object |
grid object or grid string name | |
data | object |
the grid data object | |
fx | object |
a dict with a array what should be filterd by the grid | |
append_to | string |
"#filter" |
id name of the DOM oject where the filter should be appened |
Example
var jqu = new Jqgrid_utils();
var run_me_once = true;
gridComplete: async function(){
if(run_me_once)
{
await jqu.set_filter(this, data, {material:[],section:[]}, '#filter');
run_me_once = false;
}
},
⏏
module.exports#_filter() private function of set_filter
Kind: Exported function
- This forum has 0 topics, and was last updated 8 months, 3 weeks ago by .
- Oh, bother! No topics were found here.