Skip to content

Commit

Permalink
Fix #17 - add cell renderer for boolean type
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Feb 16, 2018
1 parent 106bd92 commit 35ba60d
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 207 deletions.
8 changes: 8 additions & 0 deletions .classpath
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="C:/bbj/lib/basiscomponents.jar"/>
<classpathentry kind="lib" path="C:/bbj/lib/gson-2.3.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
4 changes: 4 additions & 0 deletions BBjGridExWidget.bbj
Expand Up @@ -571,6 +571,10 @@ class public BBjGridExWidget extends BBjWidget
node!.addProperty("filter","date")
break

case Types.BOOLEAN
node!.addProperty("filter","boolean")
break


case default
node!.addProperty("filter","agTextColumnFilter")
Expand Down
71 changes: 71 additions & 0 deletions Demo/d.bbj
@@ -0,0 +1,71 @@
REM /**
REM * d.bbj
REM * @author Hyyan-Basis
REM *
REM */
use com.google.gson.JsonParser
use com.google.gson.Gson
use com.google.gson.JsonObject
use java.util.HashMap
use java.util.Iterator
use java.lang.Integer
use java.util.Collection
use java.util.ArrayList

class public Foo

field public BBjString firstname$
field public BBjString lastname$
classend

json$ = "[{firstname: ""Hyyan"",lastname:""AF""},{firstname:""Foo"",lastname:""Bar""}]"


declare JsonParser parser!
parser! = new JsonParser()

array! = parser!.parse(json$).getAsJsonArray()

it! = array!.iterator()
while (it!.hasNext())
next! = it!.next()
print next!.getAsJsonObject().get("firstname").getAsBoolean()
wend

REM obj! = new JsonObject()
REM obj!.addProperty("id", Integer.valueOf(5))
REM
REM declare ArrayList c!
REM c! = new ArrayList()
REM c!.add("5")
REM c!.add(obj!)
REM
REM declare Gson g!
REM
REM g! = new Gson()
REM print g!.toJson(c!)

REM parse! = new JsonParser()
REM obj! = new JsonObject()
REM obj!.addProperty("id", Integer.valueOf(5))
REM
REM obj2! = new JsonObject()
REM obj2!.addProperty("id2" , Integer.valueOf(2))
REM
REM obj!.add("foo",obj2!)
REM
REM it! = m!.entrySet().iterator()
REM while (it!.hasNext())
REM next! = it!.next()
REM print next!.getKey() + " - " + str(next!.getValue()) + "\n"
REM wend
REM
REM print m!.toString()




REM ret! = parse!.parse("{id: '5'}").getAsJsonObject()
REM print ret!.get("id").getAsDouble()
REM print ret!.toString()
REM print ret!.get("id").getAsInt()
28 changes: 24 additions & 4 deletions js/BBjGridExWidget.js
Expand Up @@ -13,6 +13,10 @@ bbj_grid_supported_value_formatter = {
'agNumberColumnFilter': bbj_grid_widget_get_value_formatter_number
}

bbj_grid_supported_value_renderer = {
'boolean': bbj_grid_widget_get_value_renderer_boolean
}

function bbj_grid_widget_post_event(ev) {
window.basisDispatchCustomEvent(ev, ev.payload);
}
Expand Down Expand Up @@ -185,7 +189,10 @@ function bbj_grid_widget_init(container, license, data, options) {

for (var i in options.columnDefs) {
options.columnDefs[i].cellStyle = bbj_grid_widget_cell_render;
options.columnDefs[i].valueFormatter = bbj_grid_widget_get_value_formatter(
options.columnDefs[i].valueFormatter = bbj_grid_widget_format_value(
options.columnDefs[i].filter
);
options.columnDefs[i].cellRenderer = bbj_grid_widget_render_value(
options.columnDefs[i].filter
);
}
Expand Down Expand Up @@ -268,14 +275,17 @@ function bbj_grid_widget_set_state(state) {
$doc.bbj_grid_widget.columnApi.setColumnState(state);
}

function bbj_grid_widget_get_value_formatter(filter) {

function bbj_grid_widget_format_value(filter) {
return bbj_grid_supported_value_formatter && bbj_grid_supported_value_formatter.hasOwnProperty(filter) ?
bbj_grid_supported_value_formatter[filter] : null;
}

function bbj_grid_widget_get_value_formatter_date(data) {
function bbj_grid_widget_render_value(renderer) {
return bbj_grid_supported_value_renderer && bbj_grid_supported_value_renderer.hasOwnProperty(renderer) ?
bbj_grid_supported_value_renderer[renderer] : null;
}

function bbj_grid_widget_get_value_formatter_date(data) {
if (
($doc.bbj_grid_widget_meta && $doc.bbj_grid_widget_meta.hasOwnProperty(data.colDef.field)) &&
$doc.bbj_grid_widget_meta[data.colDef.field].hasOwnProperty('MASK')
Expand All @@ -300,6 +310,16 @@ function bbj_grid_widget_get_value_formatter_number(data) {
} else return data.value;
}

function bbj_grid_widget_get_value_renderer_boolean(data) {

if (data.value) {
return '<span>&#x2714;</span>'
} else {
return '<span>&#x2718;</span>'
}

}

function bbj_grid_widget_set_data(json, options) {

var container = $doc.getElementById('grid');
Expand Down
117 changes: 0 additions & 117 deletions js/format.js

This file was deleted.

86 changes: 0 additions & 86 deletions js/masks.js

This file was deleted.

0 comments on commit 35ba60d

Please sign in to comment.