Skip to content

Commit

Permalink
feat: setTheme can set the theme before/after the grid is renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Jul 11, 2019
1 parent dd431a1 commit cf965bc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
60 changes: 36 additions & 24 deletions BBjGridExWidget.bbj
Expand Up @@ -737,6 +737,13 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
rem */
field public BBjString DataPathTemplate! = null()
rem /**
rem * Set the grid theme
rem *
rem * <br><b><small>#Configuration</small></b>
rem * <br><b><small>#API</small></b>
rem */
field public BBjString Theme! = "balham"
rem /**
rem * The grid languages manager
rem */
field protected BBjGridExWidgetLanguageManager LanguageManager! = new BBjGridExWidgetLanguageManager()
Expand Down Expand Up @@ -1167,15 +1174,6 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns

html$ = #getTemplate()

if(len(html$) = 0) then
ch=unt
open (ch)"BBjGridExWidget/client/index.html"
read record (ch,siz=5512000)html$
close (ch)
FI

html$ = #parseTemplate(html$)

if (info(3,6)<>"5" and #Debug>0) then
call "BBjGridExWidget/util/EnableDebugger.bbj"
FI
Expand Down Expand Up @@ -1515,7 +1513,7 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
rem */
method public void setColumnHeaderAlignment(BBjString field!, BBjNumber align!)
#getColumn(field!).setHeaderAlignment(align!)
methodend
methodend
rem /**
rem * Sets the default column width for all columns
rem *
Expand Down Expand Up @@ -2507,21 +2505,27 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
rem /**
rem * Set the grid theme
rem *
rem * <br><b><small>#Configuration</small></b>
rem * <br><b><small>#API</small></b>
rem *
rem * @param BBjString theme$
rem *
rem * @see getThemes()
rem */
method public void setTheme(BBjString theme$)
if pos(theme$="dark#fresh#blue#bootstrap#material#balham#balham-dark")>0 then
#Theme! = theme$

if(#IsReady!) then
if info(3,6)="5" then
s$="$doc.getElementById('" + str(#GRIDID$) + "').className='ag-theme-"+theme$+"';"
else
s$="document.getElementById('" + str(#GRIDID$) + "').className='ag-theme-"+theme$+"';"
FI

#executeScript(s$)
else
template! = #getTemplate()
#HTMLView!.setText(template!)
FI
methodend
rem /**
Expand Down Expand Up @@ -2953,19 +2957,6 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
#executeScript("gw_hideOverlay('" + #GRIDID$ + "')")
methodend
rem /**
rem * Parse the grid html template
rem *
rem * @param BBjString template$ Template string
rem *
rem * @return BBjString parsed template
rem */
method protected BBjString parseTemplate(BBjString template$)
temp! = template$
temp! = temp!.replaceAll("__id__" , #GRIDID$)
temp! = temp!.replaceAll("__lang__", #getLanguageManager().getLanguage())
methodret str(temp!)
methodend
rem /**
rem * Fires an event
rem *
rem * @param Int type! The event's type
Expand All @@ -2984,6 +2975,27 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
method protected void updateClientWithInterests()
#executeScript("gw_updateContext('" + #GRIDID$ + "', 'interests','" + new Gson().toJson(#getInterests()) + "')")
methodend
rem /**
rem * Get the grid template
rem *
rem * @return BBjString parsed html template
rem */
method protected BBjString getTemplate()
html$ = #Template$

if(len(html$) = 0) then
ch=unt
open (ch)"BBjGridExWidget/client/index.html"
read record (ch,siz=5512000)html$
close (ch)
FI

html! = html$
html! = html!.replaceAll("__id__" , #GRIDID$)
html! = html!.replaceAll("__lang__", #getLanguageManager().getLanguage())
html! = html!.replaceAll("__THEME__", #getTheme())
methodret html!
methodend

method protected void handleStateChangedEvent(BBjString detail$, BBjNumber type!)
event! = #getColumnState()
Expand Down
2 changes: 1 addition & 1 deletion Demo/assets/templates/grid-template-with-font-awesome.html
Expand Up @@ -25,7 +25,7 @@
<div
id="__id__"
style="height: 100%"
class="ag-theme-balham">
class="ag-theme-__THEME__">
</div>
</body>

Expand Down
2 changes: 1 addition & 1 deletion client/index.html
Expand Up @@ -24,7 +24,7 @@
<div
id="__id__"
style="height: 100%"
class="ag-theme-balham">
class="ag-theme-__THEME__">
</div>
</body>

Expand Down

0 comments on commit cf965bc

Please sign in to comment.