Skip to content

Commit 10f89a5

Browse files
authored
Merge pull request #7 from ModusCreateOrg/tree-2
Modified example to sync with the tree article
2 parents 44fed66 + 2e02f11 commit 10f89a5

File tree

8 files changed

+255
-249
lines changed

8 files changed

+255
-249
lines changed

11-tree/a-basic-tree/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

11-tree/a-basic-tree/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"dependencies": {
66
"ag-grid": "^15.0.0",
7+
"ag-grid-enterprise": "^15.0.0",
78
"ag-grid-react": "^15.0.0",
89
"autoprefixer": "7.1.6",
910
"babel-core": "6.26.0",

11-tree/a-basic-tree/src/App.js

Lines changed: 117 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,124 @@
11
import React, { Component } from 'react';
2-
import Tree from './Tree';
3-
import './App.css';
2+
import { AgGridReact } from 'ag-grid-react';
3+
import 'ag-grid/dist/styles/ag-grid.css';
4+
import 'ag-grid/dist/styles/ag-theme-material.css';
5+
import 'ag-grid-enterprise';
6+
7+
import {LicenseManager} from "ag-grid-enterprise/main";
8+
// The tree view from ag-Grid requires an enterprise license and a product key
9+
// Pricing: https://www.ag-grid.com/license-pricing.php
10+
// Trial: https://www.ag-grid.com/start-trial.php
11+
LicenseManager.setLicenseKey("your license key");
12+
13+
const data = [
14+
{
15+
orgHierarchy: ['Erica Rogers'],
16+
jobTitle: 'CEO',
17+
employmentType: 'Permanent',
18+
19+
},
20+
{
21+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett'],
22+
jobTitle: 'Exec. Vice President',
23+
employmentType: 'Permanent',
24+
25+
},
26+
{
27+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Esther Baker'],
28+
jobTitle: 'Director of Operations',
29+
employmentType: 'Permanent',
30+
31+
},
32+
{
33+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Esther Baker', 'Brittany Hanson'],
34+
jobTitle: 'Fleet Coordinator',
35+
employmentType: 'Permanent',
36+
37+
},
38+
{
39+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Esther Baker', 'Brittany Hanson', 'Leah Flowers'],
40+
jobTitle: 'Parts Technician',
41+
employmentType: 'Contract',
42+
43+
},
44+
{
45+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Esther Baker', 'Brittany Hanson', 'Tammy Sutton'],
46+
jobTitle: 'Service Technician',
47+
employmentType: 'Contract',
48+
49+
},
50+
{
51+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Esther Baker', 'Derek Paul'],
52+
jobTitle: 'Inventory Control',
53+
employmentType: 'Permanent',
54+
55+
},
56+
{
57+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Francis Strickland'],
58+
jobTitle: 'VP Sales',
59+
employmentType: 'Permanent',
60+
61+
},
62+
{
63+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Francis Strickland', 'Morris Hanson'],
64+
jobTitle: 'Sales Manager',
65+
employmentType: 'Permanent',
66+
67+
},
68+
{
69+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Francis Strickland', 'Todd Tyler'],
70+
jobTitle: 'Sales Executive',
71+
employmentType: 'Contract',
72+
73+
},
74+
{
75+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Francis Strickland', 'Bennie Wise'],
76+
jobTitle: 'Sales Executive',
77+
employmentType: 'Contract',
78+
79+
},
80+
{
81+
orgHierarchy: ['Erica Rogers', 'Malcolm Barrett', 'Francis Strickland', 'Joel Cooper'],
82+
jobTitle: 'Sales Executive',
83+
employmentType: 'Permanent',
84+
85+
}
86+
];
487

588
class App extends Component {
6-
render() {
89+
columns = [
90+
{
91+
field: 'jobTitle'
92+
},
93+
{
94+
field: 'employmentType'
95+
}
96+
]
97+
98+
getDataPath = (data) => {
99+
return data.orgHierarchy;
100+
}
101+
102+
autoGroupColumnDef = {
103+
headerName: 'Organisation Hierarchy',
104+
width: 300,
105+
cellRendererParams: {
106+
suppressCount: true
107+
}
108+
}
109+
110+
render () {
7111
return (
8-
<Tree/>
112+
<div className="ag-theme-material">
113+
<AgGridReact
114+
containerStyle={{height: '400px'}}
115+
columnDefs={this.columns}
116+
rowData={data}
117+
treeData={true}
118+
getDataPath={this.getDataPath}
119+
autoGroupColumnDef={this.autoGroupColumnDef}
120+
/>
121+
</div>
9122
);
10123
}
11124
}

11-tree/a-basic-tree/src/Tree.js

Lines changed: 0 additions & 115 deletions
This file was deleted.

11-tree/b-advanced-tree/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

11-tree/b-advanced-tree/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"dependencies": {
66
"ag-grid": "^15.0.0",
7+
"ag-grid-enterprise": "^15.0.0",
78
"ag-grid-react": "^15.0.0",
89
"autoprefixer": "7.1.6",
910
"babel-core": "6.26.0",

0 commit comments

Comments
 (0)