-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·46 lines (32 loc) · 1.33 KB
/
index.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
'use strict';
var Hypergrid = require('fin-hypergrid'),
DataSourceLocal = require('datasaur-local'),
DataSourceSearchable = require('datasaur-searchable'),
DataSourceTreeView = require('datasaur-tree-view'),
treeViewPlugin = require('fin-hypergrid-tree-view-plugin'),
data = require('./data-sorted');
window.onload = function() {
// Build the data source
var local = new DataSourceLocal,
searchableByID = new DataSourceSearchable(local, { primaryKey: 'ID' }),
searchableByParentID = new DataSourceSearchable(searchableByID, { primaryKey: 'parentID' }),
dataSource = new DataSourceTreeView(searchableByParentID);
var grid = new Hypergrid({
Behavior: require('fin-hypergrid/src/behaviors/JSON'),
dataSource: dataSource
}),
treeViewOptions = { treeColumn: 'State' },
treeViewPluginSpec = [treeViewPlugin, treeViewOptions],
plugins = [treeViewPluginSpec];
grid.installPlugins(plugins);
grid.setData(data);
grid.properties.renderFalsy = true;
grid.behavior.setColumnProperties(grid.behavior.columnEnum.STATE, {
halign: 'left'
});
window.grid = grid;
var checkbox = document.querySelector('input[type=checkbox]');
checkbox.onclick = function() {
grid.plugins.treeView.join = this.checked;
};
};