Skip to content

Commit

Permalink
demos: add row styleing demo
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Jun 28, 2019
1 parent 6c30fa9 commit 4677912
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions Demo/RowsConditionalStylingDemo.bbj
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

0 comments on commit 4677912

Please sign in to comment.