Skip to content

Commit

Permalink
demos: add CustomGridDemo
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Jul 29, 2019
1 parent 06a92b5 commit 9b4351d
Showing 1 changed file with 117 additions and 0 deletions.
117 changes: 117 additions & 0 deletions demo/CustomGridDemo.bbj
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
rem /**
rem * This file is part of the BBjGridExWidget plugin.
rem * (c) Basis Europe <eu@basis.com>
rem *
rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use com.basiscomponents.db.ResultSet
use com.basiscomponents.db.DataRow
use com.basiscomponents.bc.SqlQueryBC

? 'HIDE'

class public CustomGridDemo extends BBjGridExWidget
rem /**
rem * An attribute record which can be used to override the column's attributes fetched from the resultset
rem * or applied using the api methods
rem * This field is honored only when <i>setData()</i> method is called
rem */
field public DataRow AttributesRecord! = null()
rem /**
rem * Construct new grid
rem */
method public CustomGridDemo(BBjWindow wnd!, BBjNumber id!, BBjNumber x!, BBjNumber y!, BBjNumber w!, BBjNumber h! , BBjString template$)
#super!(wnd!,id!,x!,y!,w!,h!,template$)
methodend
rem /**
rem * Construct new grid
rem */
method public CustomGridDemo(BBjWindow wnd!, BBjNumber id!, BBjNumber x!, BBjNumber y!, BBjNumber w!, BBjNumber h!)
#super!(wnd!,id!,x!,y!,w!,h!,"")
methodend
rem /**
rem * Construct new grid
rem */
method public CustomGridDemo(BBjChildWindow wnd!,BBjString template$)
#super!(wnd!,template$)
methodend
rem /**
rem * Construct new grid
rem */
method public CustomGridDemo(BBjChildWindow wnd!)
#super!(wnd!,"")
methodend
rem /**
rem * @override
rem *
rem * Override the setData method in order to apply the attributes record
rem */
method public void setData(ResultSet rs!,BBjNumber render! , BBjNumber addAll! , BBjString indexdBy$)
#super!.setData(rs!, 0, addAll!, indexdBy$)

if rs! <> NULL() then
if (#getAttributesRecord() <> null()) then
rsa! = new ResultSet()
rsa!.add(#getAttributesRecord())
#super!.buildColumnsFromResultSet(rsa!, addAll!)
FI
FI

if(render! = 1) then
#super!.render()
FI
methodend

classend

declare auto BBjTopLevelWindow wnd!
declare CustomGridDemo grid!

wnd! = BBjAPI().openSysGui("X0").addWindow(10,10,800,600,"Simple CD-Store Demo")
wnd!.setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd!.setCallback(BBjAPI.ON_RESIZE,"resize")

gosub main
process_events

rem /**
rem * Retrive the data from the database and configure the grid
rem */
main:
declare SqlQueryBC sbc!
declare ResultSet rs!
declare DataRow ar!

sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore"))
rs! = sbc!.retrieve("SELECT CDNUMBER , TITLE , PLAYINGTIME FROM CDINVENTORY")

ar! = new DataRow()
ar!.setFieldValue("CDNUMBER",java.sql.Types.INTEGER,null())
ar!.setFieldAttribute("CDNUMBER","LABEL","ID")

ar!.setFieldValue("PLAYINGTIME",java.sql.Types.INTEGER,null())
ar!.setFieldAttribute("PLAYINGTIME","MASK","##,##0.00")

grid! = new CustomGridDemo(wnd!,100,0,0,800,600)
grid!.setAttributesRecord(ar!)
grid!.setData(rs!)
return

rem /**
rem * Listen to the BBjTopLevelWindow resize events and
rem * resize the grid to fill the available space.
rem */
resize:
ev! = BBjAPI().getLastEvent()
w=ev!.getWidth()
h=ev!.getHeight()
grid!.setSize(w,h)
return

rem /**
rem * Close the demo
rem */
byebye:
bye

0 comments on commit 9b4351d

Please sign in to comment.