-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |