Skip to content

Commit

Permalink
Fix #42 - Evaluate OPTS string to replace comma and dot character in …
Browse files Browse the repository at this point in the history
…number masks
  • Loading branch information
hyyan committed May 11, 2018
1 parent c235e2b commit e139091
Show file tree
Hide file tree
Showing 6 changed files with 561 additions and 86 deletions.
10 changes: 8 additions & 2 deletions BBjGridExWidget.bbj
Expand Up @@ -1579,11 +1579,17 @@ class public BBjGridExWidget extends BBjWidget
autoGroupColumnDef!.add("cellRendererParams",autoGroupColumnDefCellRendererParams!)
options!.add("autoGroupColumnDef",autoGroupColumnDef!)
options!.add("columnDefs",cdef!)
rem the following are not supported ag-grid options , by they are required by plugin js code
rem the following are not supported by ag-grid options but they are required by plugin js code
options!.addProperty("__getRowNodeId",#RowNodeId$)
options!.addProperty("__getParentNodeId",#ParentNodeId$)
options!.addProperty("__enterKeyBehavior",#EnterKeyBehavior$)
options!.addProperty("__isTree",tree!)

comma$=",";dot$=".";a$=opts
if AND ( a$(3,1), $02$ ) = $02$ then comma$=a$(5,1) ; dot$=a$(6,1) fi
options!.addProperty("__numberGroupSep",comma$)
options!.addProperty("__numberDecimalSep",dot$)

#HTMLView!.executeScript("gw_setData("+data$+","+gson!.toJson(options!)+",'" + #LicenseKey$ + "')")
methodend

Expand Down Expand Up @@ -1658,7 +1664,7 @@ class public BBjGridExWidget extends BBjWidget

editable! = 0
editable!= num(cd!.getFieldAttribute(f$,"EDITABLE",err=*next))

if editable! > 0 and #Editable! > 0 then
node!.addProperty("editable",1)
else
Expand Down
21 changes: 18 additions & 3 deletions Demo/DatatypesDemo.bbj
Expand Up @@ -22,6 +22,19 @@ grid!.setEnableFloatingFilter(1)
wnd! .setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd! .setCallback(BBjAPI.ON_RESIZE,"resize")

rem /**
rem * @see http://documentation.basis.com/BASISHelp/WebHelp/commands2/opts_variable.htm
rem * Set the default group and deciaml separator for numbers masking
rem *
rem * To override these global option for a specific column set
rem * RENDERER_GROUP_SEPARATOR and RENDERER_DECIMAL_SEPARATOR meta on the column level
rem */
a$=opts
a$(3,1)=ior(a$(3,1),$02$)
a$(5,1)=","; rem set numbers group separator
a$(6,1)="."; rem set numbers decimal separator
setopts A$

gosub prepareGrid
gosub fillGrid

Expand All @@ -31,10 +44,9 @@ process_events
fillGrid:

rs! = new ResultSet()


i=1
x=2222.1312345
x=1234

for j=1 to 2

Expand Down Expand Up @@ -91,7 +103,10 @@ prepareGrid:
ar!.setFieldValue("DATE",java.sql.Types.DATE,"2013-02-01")
ar!.setFieldValue("TIMESTAMP",java.sql.Types.TIMESTAMP,"2016-11-12 23:22:00")

ar!.setFieldAttribute("DOUBLE","RENDERER_MASK","-### ##0.0000"); rem or RENDERER_MASK
ar!.setFieldAttribute("DOUBLE","MASK","##,##.0"); rem or RENDERER_MASK
rem ar!.setFieldAttribute("DOUBLE","RENDERER_GROUP_SEPARATOR","G"); rem change group separator
rem ar!.setFieldAttribute("DOUBLE","RENDERER_DECIMAL_SEPARATOR","D"); rem change decimal separator

ar!.setFieldAttribute("DOUBLE","LABEL","A Double Value")

REM this is also the default:
Expand Down
6 changes: 3 additions & 3 deletions js/dist/agc-basic-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/bbj-grid-widget.min.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion js/src/init.js
Expand Up @@ -29,6 +29,10 @@ export function gw_getSupportedColumnTypes() {

"basic-number": {
cellRenderer: 'BasicNumbersRenderer',
cellRendererParams: {
RENDERER_GROUP_SEPARATOR: '.',
RENDERER_DECIMAL_SEPARATOR: ','
},
cellEditor: 'BasicNumbersEditor',
filter: 'agNumberColumnFilter',
filterParams: {
Expand Down Expand Up @@ -128,12 +132,18 @@ export function gw_init(container, license, data, defaultOptions = {}) {

if (agGrid.LicenseManager && license) agGrid.LicenseManager.setLicenseKey(license);

let types = gw_getSupportedColumnTypes();

//override numbers group and decimal separators
types['basic-number']['cellRendererParams']['RENDERER_GROUP_SEPARATOR'] = defaultOptions.__numberGroupSep;
types['basic-number']['cellRendererParams']['RENDERER_DECIMAL_SEPARATOR'] = defaultOptions.__numberDecimalSep;

let options = Object.assign(defaultOptions, {

rowData: data,
getDocument: () => $doc,
columnTypes: gw_getSupportedColumnTypes(),
components: gw_getDefaultComponents(),
columnTypes: types,

onRowDoubleClicked: gw_onRowDoubleClicked,
onRowSelected: gw_onRowSelected,
Expand Down

0 comments on commit e139091

Please sign in to comment.