-
Notifications
You must be signed in to change notification settings - Fork 7
/
state.js
50 lines (43 loc) · 1.14 KB
/
state.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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': []
});
}