patch row event example

This commit is contained in:
AllenFang 2018-08-15 22:51:59 +08:00
parent bd410e7303
commit 41cc6b01af

View File

@ -1,5 +1,5 @@
/* eslint no-unused-vars: 0 */ /* eslint no-unused-vars: 0 */
/* eslint no-alert: 0 */ /* eslint no-console: 0 */
import React from 'react'; import React from 'react';
import BootstrapTable from 'react-bootstrap-table-next'; import BootstrapTable from 'react-bootstrap-table-next';
@ -21,7 +21,10 @@ const columns = [{
const rowEvents = { const rowEvents = {
onClick: (e, row, rowIndex) => { onClick: (e, row, rowIndex) => {
alert(`clicked on row with index: ${rowIndex}`); console.log(`clicked on row with index: ${rowIndex}`);
},
onMouseEnter: (e, row, rowIndex) => {
console.log(`enter on row with index: ${rowIndex}`);
} }
}; };
@ -41,7 +44,10 @@ const columns = [{
const rowEvents = { const rowEvents = {
onClick: (e, row, rowIndex) => { onClick: (e, row, rowIndex) => {
alert(\`clicked on row with index: \${rowIndex}\`); console.log(\`clicked on row with index: \${rowIndex}\`);
},
onMouseEnter: (e, row, rowIndex) => {
console.log(\`enter on row with index: \${rowIndex}\`);
} }
}; };
@ -50,7 +56,7 @@ const rowEvents = {
export default () => ( export default () => (
<div> <div>
<h3>Try to click on any rows</h3> <h3>Try to click or hover on any rows</h3>
<BootstrapTable keyField="id" data={ products } columns={ columns } rowEvents={ rowEvents } /> <BootstrapTable keyField="id" data={ products } columns={ columns } rowEvents={ rowEvents } />
<Code>{ sourceCode }</Code> <Code>{ sourceCode }</Code>
</div> </div>