Skip to content

Commit

Permalink
resolve #44
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Aug 3, 2018
1 parent 612b991 commit 8b6c8b3
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 38 deletions.
76 changes: 41 additions & 35 deletions BBjGridExWidget.bbj
Expand Up @@ -373,9 +373,7 @@ class public BBjGridExWidget extends BBjWidget
field public DataRow AttributesRecord!
field private BBjNumber Editing! = 0
field private HashMap ColumnGroups! = new HashMap()

field public static BBjNumber Debug=0

rem /**
rem * disabled default constructor
rem */
Expand Down Expand Up @@ -405,30 +403,28 @@ class public BBjGridExWidget extends BBjWidget

if (f_init!) then
html$="<html><body><script></script><div id='eventTransporterDiv' onClick='window.basisDispatchCustomEvent(event, event.payload)'></div><div id=""grid"" style=""height: 100%"" class=""ag-theme-balham""></div></body></html>"
if (info(3,6)<>"5" and #Debug>0) then
call "BBjGridExWidget/util/EnableDebugger.bbj"
fi

if (info(3,6)<>"5" and #Debug>0) then
call "BBjGridExWidget/util/EnableDebugger.bbj"
fi

htmlview! = #getCanvas().addHtmlView(101,0,0,#getCanvas().getWidth(),#getCanvas().getHeight(),"")

if (info(3,6)<>"5" and #Debug>0) then
url$ = htmlview!.getAttribute("remoteDebuggingURL")

if url$>"" then
BBjAPI().getThinClient().browse(url$)
fi
fi


REM if (htmlview!.getClientType() <> "Chromium" AND INFO(3,6)<>"5")
REM htmlview!.setText("<html><center>Error: Need the Chromium Engine in BBj 18.10 or later. Please check your BBj SAM coverage!</center></html>")
REM else
htmlview!.setCallback(BBjAPI.ON_PAGE_LOADED,#this!,"onLoad")
htmlview!.setCallback(BBjAPI.ON_NATIVE_JAVASCRIPT,#this!,"onNativeEvent")
htmlview!.setOpaque(0)
htmlview!.setText(html$)
REM fi

REM if (htmlview!.getClientType() <> "Chromium" AND INFO(3,6)<>"5")
REM htmlview!.setText("<html><center>Error: Need the Chromium Engine in BBj 18.10 or later. Please check your BBj SAM coverage!</center></html>")
REM else
htmlview!.setCallback(BBjAPI.ON_PAGE_LOADED,#this!,"onLoad")
htmlview!.setCallback(BBjAPI.ON_NATIVE_JAVASCRIPT,#this!,"onNativeEvent")
htmlview!.setOpaque(0)
htmlview!.setText(html$)
REM fi
#HTMLView!=htmlview!

if INFO(3,6)<>"5" then
Expand All @@ -443,53 +439,48 @@ REM fi
FI
methodend

method protected void injectScript(BBjString script$)
method protected void injectScript(BBjString script$)
bui = INFO(3,6)="5"
if bui then #HTMLView!.injectScript(script$) else #HTMLView!.injectScript(script$ , 1) FI
methodend

rem /**
rem * callback method after initial load
rem * does last initialization work
rem *
rem * @param BBjEvent ev!: the onLoad event
rem */
method public void onLoad(BBjEvent ev!)

rem ' only do this once
#HTMLView!.clearCallback(#HTMLView!.ON_PAGE_LOADED)
ch=unt
distBase$ = "BBjGridExWidget/js/dist"

rem include the grid
rem include the grid
gridPath$ = iff(LEN(#LicenseKey$) > 0,distBase$ + "/ag-grid-enterprise.min.noStyle.js",distBase$ +"/ag-grid.min.noStyle.js")
open (ch)gridPath$
read record (ch,siz=5512000)script$
close (ch)
#injectScript(script$)

rem include locale files
rem include locale files
locale! = stbl("!LOCALE")
locale$ = locale!.replaceAll("_","-")
dateJsLocalePath$ = distBase$ + "/i18n/Datejs/" + locale$ + ".js"
isLocale = 0
open (ch,err=*next)dateJsLocalePath$;isLocale=1

if isLocale = 0 then
close (ch)
close (ch)
dateJsLocalePath$ = distBase$ + "/i18n/Datejs/" + locale$ + ".js"
open (ch,err=*next)dateJsLocalePath$
fi

read record (ch,siz=5512000)script$
close (ch)

#injectScript(script$)

ch=unt
open (ch) distBase$ + "/bbj-grid-widget.min.js"
read record (ch,siz=5512000)script$
close (ch)
#injectScript(script$)

#IsReady! = BBjAPI.TRUE

if #RS! <> null() or #TREE! <> null() or #URL$>"" then
Expand Down Expand Up @@ -529,6 +520,12 @@ REM fi
#Editing! = 0
#handleGridCellEditingEvent(detail$,#ON_GRID_CELL_EDITING_STOPPED())
break
case "cellClicked"
#handleGridCellEditingEvent(detail$,#ON_GRID_CELL_CLICK())
break
case "cellDoubleClicked"
#handleGridCellEditingEvent(detail$,#ON_GRID_CELL_DOUBLE_CLICK())
break
case "rowEditingStarted"
#Editing! = 1
#handleGridROWEditingEvent(detail$,#ON_GRID_ROW_EDITING_STARTED())
Expand Down Expand Up @@ -667,7 +664,6 @@ REM fi
#executeScript("gw_setRowData(" + parser!.parse(row!.toJson("__ROW_INDEX")).getAsJsonArray().get(0).toString() +")")
fi
methodend

rem /**
rem * Add new row
rem *
Expand All @@ -678,7 +674,6 @@ REM fi
#RS!.add(index! , row!)
parser! = new JsonParser()
#executeScript("gw_addRows("+ str(index!) +",[" + parser!.parse(row!.toJson("__ROW_INDEX")).getAsJsonArray().get(0).toString() +"])")

methodend
rem /**
rem * Add new row
Expand All @@ -697,12 +692,12 @@ REM fi
rem */
method public void removeRow(BBjNumber index!)
if #RS!.count() <> 0 then
if #RowNodeId$ <> "__ROW_INDEX" then
if #RowNodeId$ <> "__ROW_INDEX" then
value! = #RS!.getItem(index!).getFieldAsString(#RowNodeId$)
else
else
value! = #RS!.getItem(index!).getRowKey()
fi

#RS!.remove(index!)
#executeScript("gw_removeRows(['" + str(value!) +"'])")
rem print #RS!.getItem(index!)
Expand Down Expand Up @@ -1496,6 +1491,18 @@ REM fi
methodret 5005
methodend
rem /**
rem * @return constant value to define cell click event
rem */
method public static BBjNumber ON_GRID_CELL_CLICK()
methodret 5006
methodend
rem /**
rem * @return constant value to define cell double click event
rem */
method public static BBjNumber ON_GRID_CELL_DOUBLE_CLICK()
methodret 5007
methodend
rem /**
rem * @return constant value to define row position
rem */
method public static BBjString GRID_ROWPOS_TOP()
Expand Down Expand Up @@ -1776,7 +1783,6 @@ REM fi
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$)

options!.addProperty("__locale",stbl("!LOCALE"))
#HTMLView!.executeScript("gw_setData("+data$+","+gson!.toJson(options!)+",'" + #LicenseKey$ + "')")
methodend
Expand Down
2 changes: 1 addition & 1 deletion js/dist/bbj-grid-widget.min.js

Large diffs are not rendered by default.

0 comments on commit 8b6c8b3

Please sign in to comment.