@@ -10,43 +10,42 @@ const tableData = [
1010 { key : 2 , a : '1333' , c : 'eee' , d : 2 } ,
1111] ;
1212
13- const App = React . createClass ( {
14- getInitialState ( ) {
15- this . columns = [
16- { title : 'title 1' , dataIndex : 'a' , key : 'a' , width : 100 } ,
17- { title : 'title 2' , dataIndex : 'b' , key : 'b' , width : 100 } ,
18- { title : 'title 3' , dataIndex : 'c' , key : 'c' , width : 200 } ,
19- { title : 'Operation' , dataIndex : '' , key : 'x' , render : this . renderAction } ,
20- ] ;
21- return {
22- data : tableData ,
23- expandedRowKeys : [ ] ,
24- expandIconAsCell : true ,
25- expandRowByClick : false ,
26- } ;
27- } ,
13+ class Demo extends React . Component {
14+ state = {
15+ data : tableData ,
16+ expandedRowKeys : [ ] ,
17+ expandIconAsCell : true ,
18+ expandRowByClick : false ,
19+ }
2820
29- onExpand ( expanded , record ) {
21+ onExpand = ( expanded , record ) => {
3022 console . log ( 'onExpand' , expanded , record ) ;
31- } ,
23+ }
3224
33- onExpandedRowsChange ( rows ) {
25+ onExpandedRowsChange = ( rows ) => {
3426 this . setState ( {
3527 expandedRowKeys : rows ,
3628 } ) ;
37- } ,
29+ }
3830
39- onExpandIconAsCellChange ( e ) {
31+ onExpandIconAsCellChange = ( e ) => {
4032 this . setState ( {
4133 expandIconAsCell : e . target . checked ,
4234 } ) ;
43- } ,
35+ }
4436
45- onExpandRowByClickChange ( e ) {
37+ onExpandRowByClickChange = ( e ) => {
4638 this . setState ( {
4739 expandRowByClick : e . target . checked ,
4840 } ) ;
49- } ,
41+ }
42+
43+ columns = [
44+ { title : 'title 1' , dataIndex : 'a' , key : 'a' , width : 100 } ,
45+ { title : 'title 2' , dataIndex : 'b' , key : 'b' , width : 100 } ,
46+ { title : 'title 3' , dataIndex : 'c' , key : 'c' , width : 200 } ,
47+ { title : 'Operation' , dataIndex : '' , key : 'x' , render : this . renderAction } ,
48+ ]
5049
5150 toggleButton ( ) {
5251 if ( this . state . expandedRowKeys . length ) {
@@ -55,22 +54,22 @@ const App = React.createClass({
5554 }
5655 const openAll = ( ) => this . setState ( { expandedRowKeys : [ 0 , 1 , 2 ] } ) ;
5756 return < button onClick = { openAll } > Expand All</ button > ;
58- } ,
57+ }
5958
6059 remove ( index ) {
6160 const data = this . state . data ;
6261 data . splice ( index , 1 ) ;
6362 this . setState ( { data } ) ;
64- } ,
63+ }
6564
6665 expandedRowRender ( record ) {
67- console . log ( record ) ;
66+ // console.log(record);
6867 return < p > extra: { record . a } </ p > ;
69- } ,
68+ }
7069
7170 renderAction ( o , row , index ) {
7271 return < a href = "#" onClick = { ( ) => this . remove ( index ) } > Delete</ a > ;
73- } ,
72+ }
7473
7574 render ( ) {
7675 const { expandIconAsCell, expandRowByClick, expandedRowKeys, data } = this . state ;
@@ -103,13 +102,13 @@ const App = React.createClass({
103102 />
104103 </ div >
105104 ) ;
106- } ,
107- } ) ;
105+ }
106+ }
108107
109108ReactDOM . render (
110109 < div >
111110 < h2 > expandedRowRender</ h2 >
112- < App />
111+ < Demo />
113112 </ div > ,
114113 document . getElementById ( '__react-content' )
115114) ;
0 commit comments