-
Notifications
You must be signed in to change notification settings - Fork 7
/
TreeDataDemo.bbj
126 lines (105 loc) · 4.29 KB
/
TreeDataDemo.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
120
121
122
123
124
125
126
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::BBjGridExWidgetRendererCustomHTML
use ::BBjGridExWidget/BBjGridExWidgetExpressions.bbj::BBjGridExWidgetExpressionBytesFormatter
use ::BBjGridExWidget/Demo/assets/Utilities.bbj::BBjGridExWidgetDemoUtilities
use com.basiscomponents.db.ResultSet
? 'HIDE'
BBjGridExWidgetDemoUtilities.nagAboutLicense()
declare auto BBjTopLevelWindow wnd!
declare BBjGridExWidget grid!
wnd! = BBjAPI().openSysGui("X0").addWindow(10,10,800,600,"Tree Data Demo")
wnd!.setBackColor(new BBjColor(45,52,54))
wnd!.setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd!.setCallback(BBjAPI.ON_RESIZE,"resize")
ed! = wnd!.addEditBox(200,10,8,210,25,"")
ed!.setPlaceholder("Enter a term to search ...")
ed!.setBackColor(new BBjColor(45,52,54))
ed!.setForeColor(new BBjColor(245,245,245))
ed!.setCallback(BBjAPI.ON_EDIT_MODIFY,"onSearchButton")
REM init the grid
grid! = new BBjGridExWidget(wnd!,100,0,40,wnd!.getWidth(),wnd!.getHeight() - 40)
wnd!.setBackColor(new BBjColor(45,52,54))
grid!.getOptions().setGroupDefaultExpanded(0)
grid!.getOptions().setGroupColumnLabel("BBjGridExWidget Demo")
grid!.getOptions().setShowGroupChildCount(0)
rem /**
rem * Enable tree mode and load a lodash template to convert the "filepath" property in the rows data
rem * to an JS array which will be used to compose the tree hierarchy
rem */
grid!.getOptions().setTreeData(1)
grid!.getOptions().setDataPathTemplate("<% return data.filepath.split(""\" + java.io.File.separator + """); %>")
rem /**
rem * Configure the group column (files).
rem *
rem * The grid provides be default sensible configuration , but
rem * you can hook on and change these settings using the AutoGroupColumnDefinition
rem * load a lodash template and replace the icons in the template with base64 strings of the selected images
rem * on the disk. then we create a custom html renderer. the renderer will be used inside the default group renderer
rem * (BBjGridExWidgetRendererGroupCellRenderer).
rem */
template! = BBjGridExWidgetDemoUtilities.readAssetsAsString("templates/tree-icons-custom-template.tpl")
template! = template!.replaceAll("__FILE_ICON", BBjGridExWidget.imageToBase64("BBjGridExWidget/Demo/assets/images/file.png"))
template! = template!.replaceAll("__FOLDER_ICON",BBjGridExWidget.imageToBase64("BBjGridExWidget/Demo/assets/images/folder.png"))
autoGroupDef! = grid!.getOptions().getAutoGroupColumnDefinition()
autoGroupDef!.setPinned("left")
autoGroupDef!.setWidth(500)
autoGroupDef!.getCellRenderer().setInnerRenderer(new BBjGridExWidgetRendererCustomHTML(template!))
grid!.getSidebar().setHiddenByDefault(1)
grid!.setTheme(grid!.GRID_THEME_BALHAM_DARK())
grid!.setCallback(grid!.ON_GRID_CELL_DOUBLE_CLICK(),"onSelectionEvent")
gosub main
process_events
rem /**
rem * Retrieve the data from the database and configure the grid
rem */
main:
declare ResultSet rs!
grid!.setData(BBjGridExWidgetDemoUtilities.buildResultSetFromDir("BBjGridExWidget/Demo"))
filePath! = grid!.getColumn("filepath")
filePath!.setHidden(1)
size! = grid!.getColumn("size")
size!.setAggFunc("sum")
size!.setAlignment(BBjGridExWidget.GRID_ALIGN_RIGHT() , 1)
size!.setValueFormatterExpression(new BBjGridExWidgetExpressionBytesFormatter("### ##0.00"))
grid!.setFitToGrid()
return
rem /**
rem * Set a quick filter on the grid to achieve through data search.
rem *
rem * Note : this filter is applied on the client data not the passed ResultSet
rem */
onSearchButton:
search! = ed!.getText()
grid!.setQuickFilter(search!)
return
rem /**
rem * pormpt the current selected file
rem */
onSelectionEvent:
row! = grid!.getSelectedRow()
dataRow! = row!.asDataRow()
let x=MSGBOX(str(dataRow!.getFieldAsString("filepath")) , 0 , "Selected File")
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)
grid!.setFitToGrid()
return
rem /**
rem * Close the demo
rem */
byebye:
bye