-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
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/BBjGridExWidgetColumns.bbj::BBjGridExWidgetColumn | ||
use com.basiscomponents.db.ResultSet | ||
use com.basiscomponents.bc.SqlQueryBC | ||
use com.google.gson.JsonObject | ||
|
||
? 'HIDE' | ||
|
||
declare auto BBjTopLevelWindow wnd! | ||
declare BBjGridExWidget grid! | ||
|
||
wnd! = BBjAPI().openSysGui("X0").addWindow(10,10,800,600,"Rows Conditional Styling Demo") | ||
wnd!.setCallback(BBjAPI.ON_CLOSE,"byebye") | ||
wnd!.setCallback(BBjAPI.ON_RESIZE,"resize") | ||
|
||
REM init the grid | ||
grid! = new BBjGridExWidget(wnd!,100,0,0,800,600) | ||
rem /** | ||
rem * The row style is a JSON object , in here we are attaching | ||
rem * two css propties to the object in order to change the font | ||
rem * weight and style | ||
rem */ | ||
grid!.getRowStyle().addProperty("font-weight","bold") | ||
grid!.getRowStyle().addProperty("font-style","italic") | ||
|
||
constRules! = new JsonObject() | ||
constRules!.addProperty("price-normal","data.COST < 6") | ||
constRules!.addProperty("price-above-normal","data.COST > 6 && data.COST < 8") | ||
constRules!.addProperty("price-expensive","data.COST > 8") | ||
grid!.setRowClassRules(constRules!) | ||
|
||
gosub main | ||
process_events | ||
|
||
rem /** | ||
rem * Retrive the data from the database and configure the grid | ||
rem */ | ||
main: | ||
declare SqlQueryBC sbc! | ||
declare ResultSet rs! | ||
|
||
sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore")) | ||
rs! = sbc!.retrieve("SELECT * FROM CDINVENTORY") | ||
|
||
grid!.setData(rs! , 0) | ||
grid!.addStyle("price-normal" , "{""background"": ""lightgreen !important""}") | ||
grid!.addStyle("price-above-normal" , "{""background"": ""lightsalmon !important""}") | ||
grid!.addStyle("price-expensive" , "{""background"": ""lightcoral !important""}") | ||
grid!.setTheme("bla") | ||
grid!.render() | ||
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) | ||
return | ||
|
||
rem /** | ||
rem * Close the demo | ||
rem */ | ||
byebye: | ||
bye |