From 5823e2a0e3a5084070176058bf28c0c957b6630e Mon Sep 17 00:00:00 2001 From: AllenFang Date: Sun, 16 Jul 2017 14:43:05 +0800 Subject: [PATCH] example for #1451 --- examples/js/style/demo.js | 10 ++++++++ examples/js/style/tr-style-table.js | 40 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 examples/js/style/tr-style-table.js diff --git a/examples/js/style/demo.js b/examples/js/style/demo.js index 82d6f09a2..1ccd42409 100644 --- a/examples/js/style/demo.js +++ b/examples/js/style/demo.js @@ -3,6 +3,7 @@ require('./style.css'); import React from 'react'; import TrClassStringTable from './tr-class-string-table'; import TrClassFunctionTable from './tr-class-function-table'; +import TrStyleTable from './tr-style-table'; import TdClassStringTable from './td-class-string-table'; import TdClassFunctionTable from './td-class-function-table'; import EditTdClassTable from './edit-td-class-table'; @@ -41,6 +42,15 @@ class Demo extends React.Component { +
+
+
Set String or Function for trStyle on <BootstrapTable>
+
+
Source in /examples/js/style/tr-style-table.js
+ +
+
+
Set String as classname & columnClassName on <TableHeaderColumn>(header & column)
diff --git a/examples/js/style/tr-style-table.js b/examples/js/style/tr-style-table.js new file mode 100644 index 000000000..1147869e2 --- /dev/null +++ b/examples/js/style/tr-style-table.js @@ -0,0 +1,40 @@ +/* eslint max-len: 0 */ +/* eslint no-unused-vars: 0 */ +import React from 'react'; +import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table'; + + +const products = []; + +function addProducts(quantity) { + const startId = products.length; + for (let i = 0; i < quantity; i++) { + const id = startId + i; + products.push({ + id: id, + name: 'Item name ' + id, + price: 2100 + i + }); + } +} + + +addProducts(5); + +export default class TrClassStringTable extends React.Component { + + trStyle = (row, rowIndex) => { + return { backgroundColor: '#FFFAFA' }; + } + + render() { + const selectRow = { mode: 'checkbox', bgColor: 'red' }; + return ( + + Product ID + Product Name + Product Price + + ); + } +}