File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ const onChange = (row) => {
37
37
console .log (row)
38
38
}
39
39
40
+ const onDelete = (e ) => {
41
+ console .log (e)
42
+ }
43
+
40
44
const Main = React .createClass ({
41
45
getChildContext () {
42
46
return {muiTheme: getMuiTheme (baseTheme)}
@@ -50,6 +54,7 @@ const Main = React.createClass({
50
54
return (
51
55
< EditTable
52
56
onChange= {onChange}
57
+ onDelete= {onDelete}
53
58
rows= {rows}
54
59
headerColumns= {headers}
55
60
enableDelete= {true }
Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ const onChange = (row) => {
46
46
console . log ( row )
47
47
}
48
48
49
+ const onDelete = ( e ) => {
50
+ console . log ( e )
51
+ }
52
+
49
53
const Main = React . createClass ( {
50
54
getChildContext ( ) {
51
55
return { muiTheme : getMuiTheme ( baseTheme ) }
@@ -59,6 +63,7 @@ const Main = React.createClass({
59
63
return (
60
64
< EditTable
61
65
onChange = { onChange }
66
+ onDelete = { onDelete }
62
67
rows = { rows }
63
68
headerColumns = { headers }
64
69
enableDelete = { Boolean ( true ) }
Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ module.exports = React.createClass({
14
14
headerColumns : [ ] ,
15
15
rows : [ ] ,
16
16
enableDelete : true ,
17
- onChange : function ( ) { }
17
+ onChange : function ( ) { } ,
18
+ onDelete : function ( ) { }
18
19
}
19
20
} ,
20
21
@@ -189,13 +190,18 @@ module.exports = React.createClass({
189
190
190
191
const onDeleteRow = function ( e ) {
191
192
var rows = self . state . rows
193
+ var deleteEvent = { }
192
194
rows . forEach ( ( row , i ) => {
193
- if ( rowId === i ) rows . splice ( i , 1 )
195
+ if ( rowId === i ) {
196
+ rows . splice ( i , 1 )
197
+ deleteEvent = { rowId, row}
198
+ }
194
199
} )
195
200
rows . forEach ( ( row , i ) => {
196
201
row . id = i
197
202
} )
198
203
self . setState ( { rows : rows } )
204
+ if ( deleteEvent !== { } ) this . props . onDelete ( deleteEvent )
199
205
}
200
206
201
207
const onClick = function ( e ) {
You can’t perform that action at this time.
0 commit comments