File tree Expand file tree Collapse file tree 11 files changed +166
-219
lines changed
a-controlling-cell-data/src Expand file tree Collapse file tree 11 files changed +166
-219
lines changed Original file line number Diff line number Diff line change 1
1
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 ( ) ;
3
8
4
9
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 ( ) {
6
28
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 >
8
36
) ;
9
37
}
10
38
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
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 ( ) ;
4
8
5
9
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 ( ) {
7
26
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 >
9
34
) ;
10
35
}
11
36
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
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 ( ) ;
4
8
5
9
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 ( ) {
7
26
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 >
9
34
) ;
10
35
}
11
36
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
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 ( ) ;
4
9
5
10
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 ( ) {
7
30
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 >
9
38
) ;
10
39
}
11
40
}
Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react' ;
2
+
2
3
class CustomEditor extends Component {
3
4
state = { }
5
+
4
6
componentDidMount ( ) {
5
7
this . refs . input . addEventListener ( 'blur' , this . onBlur ) ;
6
8
this . focus ( ) ;
@@ -11,13 +13,15 @@ class CustomEditor extends Component {
11
13
componentWillUnmount ( ) {
12
14
this . refs . input . removeEventListener ( 'blur' , this . onBlur ) ;
13
15
}
16
+
14
17
focus ( ) {
15
18
// focus the input slightly after dbl-click
16
19
setTimeout ( ( ) => {
17
20
const { refs : { input } } = this ;
18
21
input . focus ( ) ;
19
22
} ) ;
20
23
}
24
+
21
25
get value ( ) {
22
26
let {
23
27
props,
@@ -39,6 +43,7 @@ class CustomEditor extends Component {
39
43
value : event . target . value
40
44
} ) ;
41
45
}
46
+
42
47
render ( ) {
43
48
return < input
44
49
ref = "input"
@@ -49,5 +54,6 @@ class CustomEditor extends Component {
49
54
/> ;
50
55
}
51
56
}
57
+
52
58
export default CustomEditor ;
53
59
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments