-
Notifications
You must be signed in to change notification settings - Fork 7
/
ColumnStateDemo.bbj
119 lines (89 loc) · 3.98 KB
/
ColumnStateDemo.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidgetState
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")
tb_get! = wnd!.addButton(300,10,3,200,25,"GET STATE")
tb_get!.setEnabled(0)
tb_set! = wnd!.addButton(301,230,3,200,25,"SET STATE")
tb_refresh! = wnd!.addButton(302,450,3,200,25,"REFRESH")
tb_get!.setCallback(BBjAPI.ON_BUTTON_PUSH,"getState")
tb_set!.setCallback(BBjAPI.ON_BUTTON_PUSH,"setState")
tb_refresh!.setCallback(BBjAPI.ON_BUTTON_PUSH,"refresh")
gosub fillGrid
rem this is how you would deserialize the string behind the column state and load it into the grid:
state$="{""columns"":[{""colId"":""CDNUMBER"",""hide"":false,""aggFunc"":null,""width"":200,""pivotIndex"":null,""pinned"":null,""rowGroupIndex"":null},{""colId"":""ARTIST"",""hide"":false,""aggFunc"":null,""width"":200,""pivotIndex"":null,""pinned"":null,""rowGroupIndex"":null},{""colId"":""TITLE"",""hide"":false,""aggFunc"":null,""width"":200,""pivotIndex"":null,""pinned"":null,""rowGroupIndex"":null},{""colId"":""LABEL"",""hide"":false,""aggFunc"":null,""width"":200,""pivotIndex"":null,""pinned"":null,""rowGroupIndex"":null},{""colId"":""PLAYINGTIME"",""hide"":false,""aggFunc"":null,""width"":200,""pivotIndex"":null,""pinned"":null,""rowGroupIndex"":null}],""groups"":[],""sort"":[],""filters"":{}}"
st! = new BBjGridExWidgetState(state$)
grid!.setColumnState(st!)
process_events
fillGrid:
declare SqlQueryBC sbc!
sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore"))
rs! = sbc!.retrieve("SELECT * FROM CDINVENTORY")
grid!.addColumn("CDNUMBER","Item#")
grid!.addColumn("ARTIST","Artist Name")
grid!.addColumn("TITLE","Record Title")
grid!.addColumn("LABEL","Publisher")
grid!.addColumn("PLAYINGTIME","Playing Time (min)")
grid!.setColumnBackColor("CDNUMBER",BBjAPI().makeColor("LTGRAY"))
grid!.setColumnForeColor("CDNUMBER",BBjAPI().makeColor("BLUE"))
grid!.pinColumn("CDNUMBER","left")
grid!.setColumnWidth("CDNUMBER",120)
grid!.setColumnAlignment("CDNUMBER",grid!.GRID_ALIGN_CENTER())
grid!.setSelectionMode(grid!.GRID_SELECT_ROW())
grid!.setMultipleSelection(0)
grid!.setEnableFilter(1)
grid!.setEnableFloatingFilter(1)
groupStyle! = new JsonObject()
groupStyle!.addProperty("background","#03a9f4")
groupStyle!.addProperty("color","white")
groupStyle!.addProperty("font-weight","bolder")
groupStyle!.addProperty("border-bottom","3px solid black")
grid!.addStyle(".my-group-class" , groupStyle!)
group! = new BBjVector()
group!.addItem("CDNUMBER")
grid!.addColumnGroup("group1" , "Inventory",group! , 0 , "my-group-class")
group! = new BBjVector()
group!.addItem("ARTIST")
group!.addItem("TITLE")
grid!.addColumnGroup("group2" , "CD Information",group! , 0 , "my-group-class")
group! = new BBjVector()
group!.addItem("LABEL")
group!.addItem("PLAYINGTIME")
grid!.addColumnGroup("group3" , "Misc",group! , 0 , "my-group-class")
grid!.setData(rs!)
grid!.setCallback(grid!.ON_GRID_COLUMN_STATE_CHANGE(),"onColumnStateChange")
return
byebye:
bye
resize:
ev! = BBjAPI().getLastEvent()
grid!.setSize(ev!.getWidth(),ev!.getHeight()-30)
return
getState:
state! = grid!.getColumnState()
clipfromstr 1,state!.toString()
tb_get!.setEnabled(0)
return
setState:
if state!<>null() then
grid!.setColumnState(state!)
fi
tb_get!.setEnabled(0)
return
refresh:
grid!.setData(rs!)
return
onColumnStateChange:
tb_get!.setEnabled(1)
return