Skip to content

Commit 9370a1b

Browse files
authored
Merge pull request #6 from ModusCreateOrg/grid-features-2
light syncing with article example updates
2 parents df44633 + c28ad2e commit 9370a1b

File tree

11 files changed

+166
-219
lines changed

11 files changed

+166
-219
lines changed

10-grid-features/a-controlling-cell-data/src/App.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
11
import React, { Component } from 'react';
2-
import Grid from './Grid';
2+
import { AgGridReact } from 'ag-grid-react';
3+
import getData from './data';
4+
import 'ag-grid/dist/styles/ag-grid.css';
5+
import 'ag-grid/dist/styles/ag-theme-material.css';
6+
7+
const { data } = getData();
38

49
class App extends Component {
5-
render() {
10+
columns = [
11+
{
12+
headerName: 'Name',
13+
field: 'name'
14+
},
15+
{
16+
headerName: 'Company',
17+
field: 'company'
18+
},
19+
{
20+
headerName: 'Email',
21+
field: 'email',
22+
cellRenderer: params => {
23+
return `<a href="mailto:${params.value}">${params.value}</a>`;
24+
}
25+
}
26+
]
27+
render () {
628
return (
7-
<Grid />
29+
<div className="ag-theme-material">
30+
<AgGridReact
31+
containerStyle={{height: '400px'}}
32+
columnDefs={this.columns}
33+
rowData={data}
34+
/>
35+
</div>
836
);
937
}
1038
}

10-grid-features/a-controlling-cell-data/src/Grid.js

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

10-grid-features/b-column-locking/src/App.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
import React, { Component } from 'react';
2-
import Grid from './Grid';
3-
import './App.css';
2+
import { AgGridReact } from 'ag-grid-react';
3+
import getData from './data';
4+
import 'ag-grid/dist/styles/ag-grid.css';
5+
import 'ag-grid/dist/styles/ag-theme-material.css';
6+
7+
const { data } = getData();
48

59
class App extends Component {
6-
render() {
10+
columns = [
11+
{
12+
headerName: 'Name',
13+
field: 'name',
14+
pinned: 'left'
15+
},
16+
{
17+
headerName: 'Company',
18+
field: 'company'
19+
},
20+
{
21+
headerName: 'Email',
22+
field: 'email'
23+
}
24+
]
25+
render () {
726
return (
8-
<Grid />
27+
<div className="ag-theme-material">
28+
<AgGridReact
29+
containerStyle={{height: '400px', width: '400px'}}
30+
columnDefs={this.columns}
31+
rowData={data}
32+
/>
33+
</div>
934
);
1035
}
1136
}

10-grid-features/b-column-locking/src/Grid.js

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

10-grid-features/c-cell-editing/src/App.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
import React, { Component } from 'react';
2-
import Grid from './Grid';
3-
import './App.css';
2+
import { AgGridReact } from 'ag-grid-react';
3+
import getData from './data';
4+
import 'ag-grid/dist/styles/ag-grid.css';
5+
import 'ag-grid/dist/styles/ag-theme-material.css';
6+
7+
const { data } = getData();
48

59
class App extends Component {
6-
render() {
10+
columns = [
11+
{
12+
headerName: 'Name',
13+
field: 'name',
14+
editable: true
15+
},
16+
{
17+
headerName: 'Company',
18+
field: 'company'
19+
},
20+
{
21+
headerName: 'Email',
22+
field: 'email'
23+
}
24+
]
25+
render () {
726
return (
8-
<Grid/>
27+
<div className="ag-theme-material">
28+
<AgGridReact
29+
containerStyle={{height: '400px'}}
30+
columnDefs={this.columns}
31+
rowData={data}
32+
/>
33+
</div>
934
);
1035
}
1136
}

10-grid-features/c-cell-editing/src/Grid.js

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

10-grid-features/d-custom-editor/src/App.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
11
import React, { Component } from 'react';
2-
import Grid from './Grid';
3-
import './App.css';
2+
import { AgGridReact } from 'ag-grid-react';
3+
import getData from './data';
4+
import CustomEditor from './CustomEditor';
5+
import 'ag-grid/dist/styles/ag-grid.css';
6+
import 'ag-grid/dist/styles/ag-theme-material.css';
7+
8+
const { data } = getData();
49

510
class App extends Component {
6-
render() {
11+
columns = [
12+
{
13+
headerName: 'Name',
14+
field: 'name',
15+
editable: true
16+
},
17+
{
18+
headerName: 'Company',
19+
field: 'company'
20+
},
21+
{
22+
headerName: 'Email',
23+
field: 'email',
24+
editable: true,
25+
cellEditorFramework: CustomEditor
26+
}
27+
]
28+
29+
render () {
730
return (
8-
<Grid/>
31+
<div className="ag-theme-material">
32+
<AgGridReact
33+
containerStyle={{height: '400px'}}
34+
columnDefs={this.columns}
35+
rowData={data}
36+
/>
37+
</div>
938
);
1039
}
1140
}

10-grid-features/d-custom-editor/src/CustomEditor.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { Component } from 'react';
2+
23
class CustomEditor extends Component {
34
state = {}
5+
46
componentDidMount () {
57
this.refs.input.addEventListener('blur', this.onBlur);
68
this.focus();
@@ -11,13 +13,15 @@ class CustomEditor extends Component {
1113
componentWillUnmount () {
1214
this.refs.input.removeEventListener('blur', this.onBlur);
1315
}
16+
1417
focus () {
1518
// focus the input slightly after dbl-click
1619
setTimeout(() => {
1720
const { refs: { input } } = this;
1821
input.focus();
1922
});
2023
}
24+
2125
get value () {
2226
let {
2327
props,
@@ -39,6 +43,7 @@ class CustomEditor extends Component {
3943
value: event.target.value
4044
});
4145
}
46+
4247
render () {
4348
return <input
4449
ref="input"
@@ -49,5 +54,6 @@ class CustomEditor extends Component {
4954
/>;
5055
}
5156
}
57+
5258
export default CustomEditor;
5359

10-grid-features/d-custom-editor/src/Grid.js

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

0 commit comments

Comments
 (0)