-
Notifications
You must be signed in to change notification settings - Fork 7
/
ColumnSetupDemo.bbj
101 lines (72 loc) · 2.93 KB
/
ColumnSetupDemo.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
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use com.basiscomponents.bc.SqlQueryBC
use java.sql.Types
? '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,0,800,600)
wnd! .setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd! .setCallback(BBjAPI.ON_RESIZE,"resize")
gosub fillGrid
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)
rs!.getItem(0).setFieldAttribute("LABEL","BGCOLOR","#FF0000")
rs!.getItem(1).setFieldAttribute("LABEL","FGCOLOR","#00FF00")
grid!.setEnableFilter(1)
grid!.setEnableFloatingFilter(1)
grid!.setData(rs!,"CDNUMBER")
grid!.moveColumn("PLAYINGTIME",1)
rem grid!.setFitToGrid(1)
grid!.setCallback(grid!.ON_GRID_SELECT_ROW(),"onRowSelect")
grid!.setCallback(grid!.ON_GRID_DOUBLE_CLICK(),"onRowDoubleclick")
return
byebye:
bye
resize:
ev! = BBjAPI().getLastEvent()
grid!.setSize(ev!.getWidth(),ev!.getHeight())
return
onRowSelect:
ev! = BBjAPI().getLastEvent()
ev! = ev!.getObject()
sel! = grid!.getSelectedRows()
if INFO(3,6)="5" then
a = msgbox(ev!.getNewSelectedRows().toString(), 0, "Selection")
else
print 'SHOW',
print ev!.getRowCount(), " ROW(s) AFFECTED By Event:" , ev!.getChangedRows()
print ev!.getSelectedRowCount()," ROW(S) SELECTED By Event: ",ev!.getNewSelectedRows()
print ev!.getDeselectedRowCount()," ROW(S) DESELECTED By Event: ",ev!.getNewDeselectedRows()
print ev!.getSelectedRows().size()," ROW(S) NOW SELECTED : ", ev!.getSelectedRows()
print "------------------------------------------------------------------------"
fi
return
onRowDoubleclick:
ev! = BBjAPI().getLastEvent()
ev! = ev!.getObject()
row! = ev!.getRow()
if INFO(3,6)="5" then
a=msgbox(row!.getId() + " - " + row!.getData().get("TITLE").getAsString(),0,"DOUBLE CLICK")
else
print 'SHOW', "DOUBLE CLICK " , row!.getId() , " - " , row!.getData().get("TITLE").getAsString()
fi
return