material-ui组件[Table] OnCellClick无法用于

时间:2025-04-05 09:02:24

版本:
"react": "^15.6.2",
"material-ui": "^0.15.4",

onCellClick事件在TableRow上不起作用,需要加在Table上事件才会生效。


                <Table onCellClick={(row,column,event) => (row,column,event)}>

                    <TableHeader

                        displaySelectAll={false}

                        adjustForCheckbox={false}

                        enableSelectAll={false}

                        style={}

                    >

                        <TableRow>

                            <TableHeaderColumn style={}>{

                                formatMessage({id: 'serial number'})

                            }</TableHeaderColumn>

                            <TableHeaderColumn style={}>{

                                formatMessage({id: 'created time'})

                            }</TableHeaderColumn>

                            <TableHeaderColumn style={}>{

                                formatMessage({id: 'chip platform'})

                            }</TableHeaderColumn>

                            <TableHeaderColumn style={}>{

                                formatMessage({id: 'product portfolio'})

                            }</TableHeaderColumn>

                            <TableHeaderColumn style={}>{

                                formatMessage({id: 'status'})

                            }</TableHeaderColumn>

                            <TableHeaderColumn style={}>{

                                formatMessage({id: 'publisher'})

                            }</TableHeaderColumn>

                            <TableHeaderColumn style={}>{

                                formatMessage({id: 'release time'})

                            }</TableHeaderColumn>

                            <TableHeaderColumn style={}>{

                                formatMessage({id: 'remarks'})

                            }</TableHeaderColumn>

                            <TableHeaderColumn style={}>{

                                formatMessage({id: 'operate'})

                            }</TableHeaderColumn>

                        </TableRow>

                    </TableHeader>

                    <TableBody displayRowCheckbox={false}>

                        {certificateElements}

                    </TableBody>

                </Table>

     //接收事件

    isSelect = (row,column,event) => {

        console.log(row,column,event)

        ({

            display:true,

            num:row

        })

    }


即onCellClick on Table。