-
Notifications
You must be signed in to change notification settings - Fork 7
/
AggregationDemo.bbj
96 lines (79 loc) · 2.83 KB
/
AggregationDemo.bbj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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 ::BBjGridExWidget/BBjGridExWidgetRenderers.bbj::BBjGridExWidgetRendererGroupCellRenderer
use ::BBjGridExWidget/BBjGridExWidgetExpressions.bbj::BBjGridExWidgetExpression
use ::BBjGridExWidget/Demo/assets/Utilities.bbj::BBjGridExWidgetDemoUtilities
use com.basiscomponents.bc.SqlQueryBC
use java.sql.Types
use com.google.gson.JsonObject
? 'HIDE'
BBjGridExWidgetDemoUtilities.nagAboutLicense()
declare auto BBjTopLevelWindow wnd!
declare BBjGridExWidget grid!
wnd! = BBjAPI().openSysGui("X0").addWindow(10,10,800,600,"BBj Grid Ex Demo")
wnd! .setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd! .setCallback(BBjAPI.ON_RESIZE,"resize")
cb! = wnd!.addCheckBox(203,12,10,200,22,"Enable Read Only Mode")
cb!.setCallback(BBjAPI.ON_CHECK_OFF,"onUseCheckbox")
cb!.setCallback(BBjAPI.ON_CHECK_ON,"onUseCheckbox")
grid! = new BBjGridExWidget(wnd!,100,0,40,800,560)
grid!.getOptions().setGroupIncludeFooter(1)
grid!.getOptions().setGroupIncludeTotalFooter(1)
grid!.getOptions().setRowGroupPanelShow(grid!.GRID_GROUPPANEL_SHOW_VISIBLE())
gosub main
process_events
rem /**
rem * Retrive the data from the database and configure the grid
rem */
main:
declare SqlQueryBC sbc!
sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore"))
rs! = sbc!.retrieve("SELECT LABEL , MUSICTYPE , PLAYINGTIME , COST FROM CDINVENTORY")
grid!.setData(rs!)
rem Group rows by music type
type! = grid!.getColumn("MUSICTYPE")
type!.setRowGroup(1)
rem aggregate on playingtime
time! = grid!.getColumn("PLAYINGTIME")
time!.setEnableValue(1)
time!.setAggFunc("sum")
rem /**
rem * playingtime is a column of type string. in this case the sum agg function will not work
rem * So we setup up a value getter expression to convert the column values to numbers whenever
rem * the grid tries to aggregate on this column.
rem */
time!.setValueGetterExpression("data ? Number(data.PLAYINGTIME) : null")
rem aggregate on cost
cost! = grid!.getColumn("COST")
cost!.getValueFormatterExpression().setMask("### ##0.00")
cost!.setEnableValue(1)
cost!.setAggFunc("sum")
return
rem /**
rem * Enable / disable functions (agg , row grouping , ...)
rem */
onUseCheckbox:
useCheckbox! = cb!.isSelected()
grid!.setFunctionsReadOnly(useCheckbox!)
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 - 40)
return
rem /**
rem * Close the demo
rem */
byebye:
bye