Skip to content

Commit

Permalink
Fix #72
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Feb 19, 2019
1 parent 75f13d2 commit fd6d198
Show file tree
Hide file tree
Showing 10 changed files with 9,631 additions and 11 deletions.
18 changes: 17 additions & 1 deletion BBjGridExWidget.bbj
Expand Up @@ -497,6 +497,7 @@ class public BBjGridExWidget extends BBjWidget
map! = ev!.getEventMap()
type$ = map!.get("type")
detail$ = map!.get("detail")

switch type$
case "gw.rowSelecte"
#handleGridSelectRowEvent(detail$, "single")
Expand All @@ -509,7 +510,10 @@ class public BBjGridExWidget extends BBjWidget
break
case "gw.cellDoubleClicked"
#handleGridCellEditingEvent(detail$,#ON_GRID_CELL_DOUBLE_CLICK())
break
break
case "gw.stateChanged"
#handleStateChangedEvent(detail$,#ON_GRID_COLUMN_STATE_CHANGE())
break
case "cellEditingStarted"
#Editing! = 1
#handleGridCellEditingEvent(detail$,#ON_GRID_CELL_EDITING_STARTED())
Expand Down Expand Up @@ -1490,6 +1494,12 @@ class public BBjGridExWidget extends BBjWidget
methodret 5007
methodend
rem /**
rem * @return constant value to define grid state changes
rem */
method public static BBjNumber ON_GRID_COLUMN_STATE_CHANGE()
methodret 5008
methodend
rem /**
rem * @return constant value to define row position
rem */
method public static BBjString GRID_ROWPOS_TOP()
Expand Down Expand Up @@ -1613,6 +1623,12 @@ class public BBjGridExWidget extends BBjWidget
throw "(" + feature$ + ") is an ag-grid enterprise feature , please set a licence key to use this feature.", 256
FI
methodend

method private void handleStateChangedEvent(BBjString detail$, BBjNumber type!)
event! = #getColumnState()
#fireEvent(type!, event!)
methodend

rem /**
rem * Handle Rows Selections Event
rem *
Expand Down
13 changes: 11 additions & 2 deletions Demo/ColumnStateDemo.bbj
Expand Up @@ -15,6 +15,7 @@ declare BBjGridExWidget grid!
wnd! = BBjAPI().openSysGui("X0").addWindow(10,10,800,600,"BBj Grid Ex Demo")

grid! = new BBjGridExWidget(wnd!,100,0,30,800,570)
grid!.setCallback(grid!.ON_GRID_COLUMN_STATE_CHANGE(),"onColumnStateChange")

wnd! .setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd! .setCallback(BBjAPI.ON_RESIZE,"resize")
Expand All @@ -23,6 +24,11 @@ tb_get! = wnd!.addButton(300,10,3,200,25,"GET STATE")
tb_set! = wnd!.addButton(301,230,3,200,25,"SET STATE")
tb_refresh! = wnd!.addButton(302,450,3,200,25,"REFRESH")

rem Disable the get and set buttons by default , these buttons will be
rem enabled again when the grid state is changed
tb_get!.setEnabled(0)
tb_set!.setEnabled(0)

tb_get!.setCallback(BBjAPI.ON_BUTTON_PUSH,"getState")
tb_set!.setCallback(BBjAPI.ON_BUTTON_PUSH,"setState")
tb_refresh!.setCallback(BBjAPI.ON_BUTTON_PUSH,"refresh")
Expand Down Expand Up @@ -96,8 +102,6 @@ return
getState:
state! = grid!.getColumnState()
clipfromstr 1,state!.toString()


return

setState:
Expand All @@ -106,6 +110,11 @@ setState:
fi
return

onColumnStateChange:
tb_get!.setEnabled(1)
tb_set!.setEnabled(1)
return

refresh:
grid!.setData(rs!)
return
9,222 changes: 9,219 additions & 3 deletions js/dist/bbj-grid-widget.js

Large diffs are not rendered by default.

328 changes: 326 additions & 2 deletions js/dist/bbj-grid-widget.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/report.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/src/events.js
Expand Up @@ -10,3 +10,4 @@ export * from './events/pollyfills.js';
export * from './events/utilities.js';
export * from './events/selections.js';
export * from './events/editing.js';
export * from './events/state.js';
50 changes: 50 additions & 0 deletions js/src/events/state.js
@@ -0,0 +1,50 @@
import { gw_getGrid } from "../utilities";

/*
* This file is part of the grid project
* (c) Basis Europe <eu@basis.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

export function gw_onReadyEvent(id, e) {

// registe state debounced monitor
const stateDebouce = gw_debounce(changeEvent => {

// We skip the first render state changes
if (!gw_getGrid(id).hasOwnProperty('isFirstRender')) {
gw_getGrid(id).isFirstRender = true;
return;
}

gw_onStateChanged(id, changeEvent);
}, 500);

[
'sortChanged',
'filterChanged',
'columnVisible',
'columnPinned',
'columnResized',
'columnMoved',
'newColumnsLoaded',
'gridColumnsChanged',
'displayedColumnsChanged',
'virtualColumnsChanged',
'columnEverythingChanged',
'gridSizeChanged',
'expandOrCollapseAll',
'toolPanelVisibleChanged'
].forEach(event => {
gw_getGrid(id).options.api.addEventListener(event, stateDebouce);
});
}

export function gw_onStateChanged(id, e) {
gw_sendEvent(id, {
'type': 'gw.stateChanged',
'detail': []
});
}
5 changes: 4 additions & 1 deletion js/src/init.js
@@ -1,3 +1,5 @@
import { gw_debounce } from "./utilities";

/*
* This file is part of the grid project
* (c) Basis Europe <eu@Basis.AgGridComponents.com>
Expand Down Expand Up @@ -38,6 +40,7 @@ export function gw_setData(json, options, license) {
onRowValueChanged: e => { gw_onRowEditingsEvent(id, e) },
onCellClicked: e => { gw_onCellClickEvent(id, e) },
onCellDoubleClicked: e => { gw_onCellClickEvent(id, e) },
onGridReady: e => { gw_onReadyEvent(id,e) },
getRowNodeId: data => gw_getRowNodeId(id, data),
getContextMenuItems: params => gw_getContextMenu(id, params),
rowData: json,
Expand Down Expand Up @@ -237,7 +240,7 @@ export function gw_setData(json, options, license) {
const instance = new agGrid.Grid(container, options);
grid.instance = instance;
grid.options = options;

console.log(
`%c Grid [${id}] settings : `
, 'background: #222; color: #bada55'
Expand Down
1 change: 0 additions & 1 deletion js/src/utilities.js
Expand Up @@ -25,7 +25,6 @@ export function gw_debounce(func, wait, immediate) {
export function gw_getGlobalMeta(id, field, value, fallback = null, json = false) {

const meta = gw_getGrid(id).meta;
console.log(meta);

if (
meta && meta.hasOwnProperty(field) &&
Expand Down
2 changes: 2 additions & 0 deletions js/webpack.config.js
Expand Up @@ -12,10 +12,12 @@ module.exports = {
entry: {
"bbj-grid-widget.min": [
"core-js/fn/string/starts-with.js",
"core-js/fn/array/for-each.js",
"./src/index.js"
],
"bbj-grid-widget": [
"core-js/fn/string/starts-with.js",
"core-js/fn/array/for-each.js",
"./src/index.js"
],
},
Expand Down

0 comments on commit fd6d198

Please sign in to comment.