-
Notifications
You must be signed in to change notification settings - Fork 7
/
SidebarDemo.bbj
93 lines (65 loc) · 2.44 KB
/
SidebarDemo.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
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidgetColumnsToolpanel
use com.basiscomponents.bc.SqlQueryBC
use java.sql.Types
use com.google.gson.JsonObject
? 'HIDE'
declare auto BBjTopLevelWindow wnd!
declare auto BBjListButton lb_db!
declare auto BBjListButton lb_tbl!
declare auto BBjToolButton btn_fit!
declare BBjGridExWidget grid!
wnd! = BBjAPI().openSysGui("X0").addWindow(10,10,800,600,"BBj Grid Ex Demo")
grid! = new BBjGridExWidget(wnd!,100,0,30,800,570)
wnd! .setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd! .setCallback(BBjAPI.ON_RESIZE,"resize")
if (info(3,6)<>"5") then
wnd!.setCallback(BBjAPI.ON_KEYPRESS,"onWinKeypress")
fi
sidebarToggle! = wnd!.addButton(300,10,3,200,25,"Toggle Sidebar")
toolpanelToggle! = wnd!.addButton(301,230,3,200,25,"Toggle Columns Toolpanel")
refresh! = wnd!.addButton(302,460,3,200,25,"Refresh Data")
sidebarToggle!.setCallback(BBjAPI.ON_BUTTON_PUSH,"sidebarToggle")
toolpanelToggle!.setCallback(BBjAPI.ON_BUTTON_PUSH,"toolpanelToggle")
refresh!.setCallback(BBjAPI.ON_BUTTON_PUSH,"refreshData")
sidebarState! = 1
toolpanelState! = 0
gosub fillGrid
process_events
fillGrid:
declare SqlQueryBC sbc!
sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore"))
rs! = sbc!.retrieve("SELECT * FROM CDINVENTORY")
rs!.setAttribute(6,"TOOLPANEL_CLASS","music-type")
grid!.setFunctionsReadOnly(0)
grid!.setRowGroupPanelShow(grid!.GRID_GROUPPANEL_SHOW_VISIBLE())
columnsToolpanel! = cast(BBjGridExWidgetColumnsToolpanel,grid!.getSidebar().getToolpanels().get(BBjGridExWidgetColumnsToolpanel.getId()))
columnsToolpanel!.setSuppressValues(1)
musicTypeStyle! = new JsonObject()
musicTypeStyle!.addProperty("background","gold")
grid!.addStyle(".music-type",musicTypeStyle!)
grid!.setData(rs!,"CDNUMBER")
return
sidebarToggle:
sidebar! = grid!.getSidebar()
sidebarState! = !sidebarState!
sidebar!.setVisible(sidebarState!)
return
toolpanelToggle:
sidebar! = grid!.getSidebar()
if toolpanelState! = 0 then
sidebar!.openToolpanel(BBjGridExWidgetColumnsToolpanel.getId())
else
sidebar!.closeToolpanel(BBjGridExWidgetColumnsToolpanel.getId())
fi
toolpanelState! = !toolpanelState!
return
refreshData:
grid!.setData(rs!,"CDNUMBER")
return
byebye:
bye
resize:
ev! = BBjAPI().getLastEvent()
grid!.setSize(ev!.getWidth(),ev!.getHeight()-30)
return