mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
Merge pull request #1023 from react-bootstrap-table/develop
20190721 release
This commit is contained in:
commit
64c113da26
@ -98,7 +98,14 @@ import overlayFactory from 'react-bootstrap-table2-overlay';
|
||||
Actually, `react-bootstrap-table-overlay` is depends on [`react-loading-overlay`](https://github.com/derrickpelletier/react-loading-overlay) and `overlayFactory` just a factory function and you can pass any props which available for `react-loading-overlay`:
|
||||
|
||||
```js
|
||||
overlay={ overlayFactory({ spinner: true, background: 'rgba(192,192,192,0.3)' }) }
|
||||
overlay={
|
||||
overlayFactory({
|
||||
spinner: true,
|
||||
styles: {
|
||||
overlay: (base) => ({...base, background: 'rgba(255, 0, 0, 0.5)'})
|
||||
}
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### <a name='caption'>caption - [String | Node]</a>
|
||||
@ -334,4 +341,4 @@ handleDataChange = ({ dataSize }) => {
|
||||
onDataSizeChange={ handleDataChange }
|
||||
....
|
||||
/>
|
||||
```
|
||||
```
|
||||
|
||||
@ -11,6 +11,7 @@ Available properties in a column object:
|
||||
* [hidden](#hidden)
|
||||
* [formatter](#formatter)
|
||||
* [formatExtraData](#formatExtraData)
|
||||
* [type](#type)
|
||||
* [sort](#sort)
|
||||
* [sortFunc](#sortFunc)
|
||||
* [sortCaret](#sortCaret)
|
||||
@ -132,6 +133,10 @@ The third argument: `components` have following specified properties:
|
||||
## <a name='formatExtraData'>column.formatExtraData - [Any]</a>
|
||||
It's only used for [`column.formatter`](#formatter), you can define any value for it and will be passed as fourth argument for [`column.formatter`](#formatter) callback function.
|
||||
|
||||
## <a name='type'>column.type - [String]</a>
|
||||
Specify the data type on column. Available value so far is `string`, `number`, `bool` and `date`. Default is `string`.
|
||||
`column.type` can be used when you enable the cell editing and want to save your cell data with correct data type.
|
||||
|
||||
## <a name='sort'>column.sort - [Bool]</a>
|
||||
Enable the column sort via a `true` value given.
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
* [expandColumnPosition](#expandColumnPosition)
|
||||
* [expandColumnRenderer](#expandColumnRenderer)
|
||||
* [expandHeaderColumnRenderer](#expandHeaderColumnRenderer)
|
||||
* [parentClassName](#parentClassName)
|
||||
|
||||
### <a name="renderer">expandRow.renderer - [Function]</a>
|
||||
|
||||
@ -25,12 +26,13 @@ Specify the content of expand row, `react-bootstrap-table2` will pass a row obje
|
||||
|
||||
#### values
|
||||
* **row**
|
||||
* **rowIndex**
|
||||
|
||||
#### examples
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: row => (
|
||||
renderer: (row, rowIndex) => (
|
||||
<div>
|
||||
<p>{ `This Expand row is belong to rowKey ${row.id}` }</p>
|
||||
<p>You can render anything here, also you can add additional data on every row object</p>
|
||||
@ -165,3 +167,24 @@ const expandRow = {
|
||||
expandColumnPosition: 'right'
|
||||
};
|
||||
```
|
||||
|
||||
### <a name='parentClassName'>expandRow.parentClassName - [String | Function]</a>
|
||||
Apply the custom class name on parent row of expanded row. For example:
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: (row) => ...,
|
||||
parentClassName: 'foo'
|
||||
};
|
||||
```
|
||||
Below case is more flexible way to custom the class name:
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: (row) => ...,
|
||||
parentClassName: (isExpanded, row, rowIndex) => {
|
||||
if (rowIndex > 2) return 'foo';
|
||||
return 'bar';
|
||||
}
|
||||
};
|
||||
```
|
||||
@ -56,12 +56,13 @@ export default (
|
||||
}
|
||||
|
||||
handleCellUpdate(row, column, newValue) {
|
||||
const newValueWithType = dataOperator.typeConvert(column.type, newValue);
|
||||
const { cellEdit } = this.props;
|
||||
const { beforeSaveCell } = cellEdit.options;
|
||||
const oldValue = _.get(row, column.dataField);
|
||||
const beforeSaveCellDone = (result = true) => {
|
||||
if (result) {
|
||||
this.doUpdate(row, column, newValue);
|
||||
this.doUpdate(row, column, newValueWithType);
|
||||
} else {
|
||||
this.escapeEditing();
|
||||
}
|
||||
@ -69,7 +70,7 @@ export default (
|
||||
if (_.isFunction(beforeSaveCell)) {
|
||||
const result = beforeSaveCell(
|
||||
oldValue,
|
||||
newValue,
|
||||
newValueWithType,
|
||||
row,
|
||||
column,
|
||||
beforeSaveCellDone
|
||||
@ -78,7 +79,7 @@ export default (
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.doUpdate(row, column, newValue);
|
||||
this.doUpdate(row, column, newValueWithType);
|
||||
}
|
||||
|
||||
doUpdate(row, column, newValue) {
|
||||
|
||||
123
packages/react-bootstrap-table2-example/examples/cell-edit/cell-edit-with-data-type.js
vendored
Normal file
123
packages/react-bootstrap-table2-example/examples/cell-edit/cell-edit-with-data-type.js
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
/* eslint prefer-template: 0 */
|
||||
import React from 'react';
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import cellEditFactory, { Type } from 'react-bootstrap-table2-editor';
|
||||
import Code from 'components/common/code-block';
|
||||
import { stockGenerator } from 'utils/common';
|
||||
|
||||
const products = stockGenerator();
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Stock ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Stock Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Price',
|
||||
type: 'number'
|
||||
}, {
|
||||
dataField: 'visible',
|
||||
text: 'Visible?',
|
||||
type: 'bool',
|
||||
editor: {
|
||||
type: Type.CHECKBOX,
|
||||
value: 'true:false'
|
||||
}
|
||||
}, {
|
||||
dataField: 'inStockDate',
|
||||
text: 'Stock Date',
|
||||
type: 'date',
|
||||
formatter: (cell) => {
|
||||
let dateObj = cell;
|
||||
if (typeof cell !== 'object') {
|
||||
dateObj = new Date(cell);
|
||||
}
|
||||
return `${('0' + dateObj.getUTCDate()).slice(-2)}/${('0' + (dateObj.getUTCMonth() + 1)).slice(-2)}/${dateObj.getUTCFullYear()}`;
|
||||
},
|
||||
editor: {
|
||||
type: Type.DATE
|
||||
}
|
||||
}];
|
||||
|
||||
const sourceCode = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import cellEditFactory from 'react-bootstrap-table2-editor';
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Stock ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Stock Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Price',
|
||||
type: 'number'
|
||||
}, {
|
||||
dataField: 'visible',
|
||||
text: 'Visible?',
|
||||
type: 'bool',
|
||||
editor: {
|
||||
type: Type.CHECKBOX,
|
||||
value: 'true:false'
|
||||
}
|
||||
}, {
|
||||
dataField: 'inStockDate',
|
||||
text: 'Stock Date',
|
||||
type: 'date',
|
||||
formatter: (cell) => {
|
||||
let dateObj = cell;
|
||||
if (typeof cell !== 'object') {
|
||||
dateObj = new Date(cell);
|
||||
}
|
||||
return \`$\{('0' + dateObj.getUTCDate()).slice(-2)}/$\{('0' + (dateObj.getUTCMonth() + 1)).slice(-2)}/$\{dateObj.getUTCFullYear()}\`;
|
||||
},
|
||||
editor: {
|
||||
type: Type.DATE
|
||||
}
|
||||
}];
|
||||
|
||||
function afterSaveCell(oldValue, newValue) {
|
||||
console.log('--after save cell--');
|
||||
console.log('New Value was apply as');
|
||||
console.log(newValue);
|
||||
console.log(\`and the type is $\{typeof newValue}\`);
|
||||
}
|
||||
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
cellEdit={ cellEditFactory({
|
||||
mode: 'click',
|
||||
blurToSave: true,
|
||||
afterSaveCell
|
||||
}) }
|
||||
/>
|
||||
`;
|
||||
|
||||
function afterSaveCell(oldValue, newValue) {
|
||||
console.log('--after save cell--');
|
||||
console.log('New Value was apply as');
|
||||
console.log(newValue);
|
||||
console.log(`and the type is ${typeof newValue}`);
|
||||
}
|
||||
|
||||
export default () => (
|
||||
<div>
|
||||
<h3>Save Cell Value with Specified Data Type</h3>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
cellEdit={ cellEditFactory({
|
||||
mode: 'click',
|
||||
blurToSave: true,
|
||||
afterSaveCell
|
||||
}) }
|
||||
/>
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div>
|
||||
);
|
||||
@ -12,8 +12,12 @@ import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter';
|
||||
|
||||
class Table extends React.Component {
|
||||
filterByPrice = filterVal =>
|
||||
products.filter(product => product.price == filterVal);
|
||||
filterByPrice = (filterVal) => {
|
||||
if (filterVal) {
|
||||
return products.filter(product => product.price == filterVal);
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
render() {
|
||||
const columns = [{
|
||||
@ -46,8 +50,12 @@ class Table extends React.Component {
|
||||
`;
|
||||
|
||||
export default class Table extends React.Component {
|
||||
filterByPrice = filterVal =>
|
||||
products.filter(product => product.price == filterVal);
|
||||
filterByPrice = (filterVal) => {
|
||||
if (filterVal) {
|
||||
return products.filter(product => product.price == filterVal);
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
render() {
|
||||
const columns = [{
|
||||
@ -67,7 +75,7 @@ export default class Table extends React.Component {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Implement a eq filter on product price column</h2>
|
||||
<h2>Implement Custom Filter</h2>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
|
||||
@ -36,7 +36,7 @@ const RemotePagination = ({ loading, data, page, sizePerPage, onTableChange, tot
|
||||
columns={ columns }
|
||||
pagination={ paginationFactory({ page, sizePerPage, totalSize }) }
|
||||
onTableChange={ onTableChange }
|
||||
overlay={ overlayFactory({ spinner: true, background: 'rgba(192,192,192,0.3)' }) }
|
||||
overlay={ overlayFactory({ spinner: true, styles: { overlay: (base) => ({...base, background: 'rgba(255, 0, 0, 0.5)'}) } }) }
|
||||
/>
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div>
|
||||
@ -101,7 +101,12 @@ const RemotePagination = ({ loading, data, page, sizePerPage, onTableChange, tot
|
||||
columns={ columns }
|
||||
pagination={ paginationFactory({ page, sizePerPage, totalSize }) }
|
||||
onTableChange={ onTableChange }
|
||||
overlay={ overlayFactory({ spinner: true, background: 'rgba(192,192,192,0.3)' }) }
|
||||
overlay={
|
||||
overlayFactory({
|
||||
spinner: true,
|
||||
styles: { overlay: base => ({ ...base, background: 'rgba(255, 0, 0, 0.5)' }) }
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div>
|
||||
|
||||
@ -18,9 +18,9 @@ const columns = [{
|
||||
}];
|
||||
|
||||
const expandRow = {
|
||||
renderer: row => (
|
||||
renderer: (row, rowIndex) => (
|
||||
<div>
|
||||
<p>{ `This Expand row is belong to rowKey ${row.id}` }</p>
|
||||
<p>{ `This Expand row is belong to rowKey ${row.id} and index: ${rowIndex}` }</p>
|
||||
<p>You can render anything here, also you can add additional data on every row object</p>
|
||||
<p>expandRow.renderer callback will pass the origin row object to you</p>
|
||||
</div>
|
||||
|
||||
106
packages/react-bootstrap-table2-example/examples/row-expand/parent-row-classname.js
vendored
Normal file
106
packages/react-bootstrap-table2-example/examples/row-expand/parent-row-classname.js
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
import React from 'react';
|
||||
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import Code from 'components/common/code-block';
|
||||
import { productsExpandRowsGenerator } from 'utils/common';
|
||||
|
||||
const products = productsExpandRowsGenerator();
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price'
|
||||
}];
|
||||
|
||||
const expandRow1 = {
|
||||
parentClassName: 'parent-expand-foo',
|
||||
renderer: row => (
|
||||
<div>
|
||||
<p>{ `This Expand row is belong to rowKey ${row.id}` }</p>
|
||||
<p>You can render anything here, also you can add additional data on every row object</p>
|
||||
<p>expandRow.renderer callback will pass the origin row object to you</p>
|
||||
</div>
|
||||
)
|
||||
};
|
||||
|
||||
const expandRow2 = {
|
||||
parentClassName: (isExpanded, row, rowIndex) => {
|
||||
if (rowIndex > 2) return 'parent-expand-foo';
|
||||
return 'parent-expand-bar';
|
||||
},
|
||||
renderer: row => (
|
||||
<div>
|
||||
<p>{ `This Expand row is belong to rowKey ${row.id}` }</p>
|
||||
<p>You can render anything here, also you can add additional data on every row object</p>
|
||||
<p>expandRow.renderer callback will pass the origin row object to you</p>
|
||||
</div>
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
const sourceCode1 = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
|
||||
const columns = // omit...
|
||||
|
||||
const expandRow = {
|
||||
parentClassName: 'parent-expand-foo',
|
||||
renderer: row => (
|
||||
<div>.....</div>
|
||||
)
|
||||
};
|
||||
|
||||
<BootstrapTable
|
||||
keyField='id'
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
expandRow={ expandRow }
|
||||
/>
|
||||
`;
|
||||
|
||||
const sourceCode2 = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
|
||||
const columns = // omit...
|
||||
|
||||
const expandRow = {
|
||||
parentClassName: (isExpanded, row, rowIndex) => {
|
||||
if (rowIndex > 2) return 'parent-expand-foo';
|
||||
return 'parent-expand-bar';
|
||||
},
|
||||
renderer: row => (
|
||||
<div>...</div>
|
||||
)
|
||||
};
|
||||
|
||||
<BootstrapTable
|
||||
keyField='id'
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
expandRow={ expandRow }
|
||||
/>
|
||||
`;
|
||||
|
||||
export default () => (
|
||||
<div>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
expandRow={ expandRow1 }
|
||||
/>
|
||||
<Code>{ sourceCode1 }</Code>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
expandRow={ expandRow2 }
|
||||
/>
|
||||
<Code>{ sourceCode2 }</Code>
|
||||
</div>
|
||||
);
|
||||
@ -69,8 +69,9 @@ const endDate = new Date();
|
||||
export const stockGenerator = (quantity = 5) =>
|
||||
Array.from({ length: quantity }, (value, index) => ({
|
||||
id: index,
|
||||
name: `Todo item ${index}`,
|
||||
name: `Stock Name ${index}`,
|
||||
price: Math.floor((Math.random() * 2) + 1),
|
||||
visible: Math.random() > 0.5,
|
||||
inStockDate:
|
||||
new Date(startDate.getTime() + Math.random() * (endDate.getTime() - startDate.getTime()))
|
||||
}));
|
||||
|
||||
@ -131,6 +131,7 @@ import TextareaEditorTable from 'examples/cell-edit/textarea-editor-table';
|
||||
import CheckboxEditorTable from 'examples/cell-edit/checkbox-editor-table';
|
||||
import DateEditorTable from 'examples/cell-edit/date-editor-table';
|
||||
import CustomEditorTable from 'examples/cell-edit/custom-editor-table';
|
||||
import CellEditorWithDataType from 'examples/cell-edit/cell-edit-with-data-type';
|
||||
|
||||
// work on row selection
|
||||
import SingleSelectionTable from 'examples/row-selection/single-selection';
|
||||
@ -164,6 +165,7 @@ import ExpandOnlyOne from 'examples/row-expand/expand-only-one';
|
||||
import CustomExpandColumn from 'examples/row-expand/custom-expand-column';
|
||||
import ExpandColumnPosition from 'examples/row-expand/expand-column-position';
|
||||
import ExpandHooks from 'examples/row-expand/expand-hooks';
|
||||
import ParentRowClassName from 'examples/row-expand/parent-row-classname';
|
||||
|
||||
// pagination
|
||||
import PaginationTable from 'examples/pagination';
|
||||
@ -377,7 +379,8 @@ storiesOf('Cell Editing', module)
|
||||
.add('Textarea Editor', () => <TextareaEditorTable />)
|
||||
.add('Checkbox Editor', () => <CheckboxEditorTable />)
|
||||
.add('Date Editor', () => <DateEditorTable />)
|
||||
.add('Custom Editor', () => <CustomEditorTable />);
|
||||
.add('Custom Editor', () => <CustomEditorTable />)
|
||||
.add('Cell Editor with Data Type', () => <CellEditorWithDataType />);
|
||||
|
||||
storiesOf('Row Selection', module)
|
||||
.addDecorator(bootstrapStyle())
|
||||
@ -412,7 +415,8 @@ storiesOf('Row Expand', module)
|
||||
.add('Expand Only One Row at The Same Time', () => <ExpandOnlyOne />)
|
||||
.add('Custom Expand Indicator', () => <CustomExpandColumn />)
|
||||
.add('Expand Column Position', () => <ExpandColumnPosition />)
|
||||
.add('Expand Hooks', () => <ExpandHooks />);
|
||||
.add('Expand Hooks', () => <ExpandHooks />)
|
||||
.add('Custom Parent Row ClassName', () => <ParentRowClassName />);
|
||||
|
||||
storiesOf('Pagination', module)
|
||||
.addDecorator(bootstrapStyle())
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
.parent-expand-foo {
|
||||
background-color: coral;
|
||||
}
|
||||
|
||||
.parent-expand-bar {
|
||||
background-color: aqua;
|
||||
}
|
||||
@ -12,3 +12,4 @@
|
||||
@import "sort/index";
|
||||
@import "search/index";
|
||||
@import "loading-overlay/index";
|
||||
@import "row-expand/index";
|
||||
@ -189,7 +189,8 @@ BootstrapTable.propTypes = {
|
||||
expandColumnPosition: PropTypes.oneOf([
|
||||
Const.INDICATOR_POSITION_LEFT,
|
||||
Const.INDICATOR_POSITION_RIGHT
|
||||
])
|
||||
]),
|
||||
parentClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
|
||||
}),
|
||||
rowStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
||||
rowEvents: PropTypes.object,
|
||||
|
||||
6
packages/react-bootstrap-table2/src/const.js
vendored
6
packages/react-bootstrap-table2/src/const.js
vendored
@ -8,5 +8,9 @@ export default {
|
||||
CHECKBOX_STATUS_INDETERMINATE: 'indeterminate',
|
||||
CHECKBOX_STATUS_UNCHECKED: 'unchecked',
|
||||
INDICATOR_POSITION_LEFT: 'left',
|
||||
INDICATOR_POSITION_RIGHT: 'right'
|
||||
INDICATOR_POSITION_RIGHT: 'right',
|
||||
TYPE_STRING: 'string',
|
||||
TYPE_NUMBER: 'number',
|
||||
TYPE_BOOLEAN: 'bool',
|
||||
TYPE_DATE: 'date'
|
||||
};
|
||||
|
||||
@ -117,6 +117,12 @@ HeaderCell.propTypes = {
|
||||
column: PropTypes.shape({
|
||||
dataField: PropTypes.string.isRequired,
|
||||
text: PropTypes.string.isRequired,
|
||||
type: PropTypes.oneOf([
|
||||
Const.TYPE_STRING,
|
||||
Const.TYPE_NUMBER,
|
||||
Const.TYPE_BOOLEAN,
|
||||
Const.TYPE_DATE
|
||||
]),
|
||||
isDummyField: PropTypes.bool,
|
||||
hidden: PropTypes.bool,
|
||||
headerFormatter: PropTypes.func,
|
||||
|
||||
@ -1,16 +1,24 @@
|
||||
/* eslint react/prop-types: 0 */
|
||||
import React from 'react';
|
||||
import cs from 'classnames';
|
||||
import ExpandRow from './expand-row';
|
||||
import _ from '../utils';
|
||||
import ExpansionContext from '../contexts/row-expand-context';
|
||||
|
||||
export default (Component) => {
|
||||
const renderWithExpansion = (props, expandRow) => {
|
||||
let parentClassName = '';
|
||||
const key = props.value;
|
||||
|
||||
const expanded = _.contains(expandRow.expanded, key);
|
||||
const isClosing = _.contains(expandRow.isClosing, key);
|
||||
const expandable = !expandRow.nonExpandable || !_.contains(expandRow.nonExpandable, key);
|
||||
if (expanded) {
|
||||
parentClassName = _.isFunction(expandRow.parentClassName) ?
|
||||
expandRow.parentClassName(expanded, props.row, props.rowIndex) :
|
||||
(expandRow.parentClassName || '');
|
||||
}
|
||||
|
||||
return [
|
||||
<Component
|
||||
{ ...props }
|
||||
@ -18,6 +26,7 @@ export default (Component) => {
|
||||
expanded={ expanded }
|
||||
expandable={ expandable }
|
||||
expandRow={ { ...expandRow } }
|
||||
className={ cs(props.className, parentClassName) }
|
||||
/>,
|
||||
expanded || isClosing ? <ExpandRow
|
||||
key={ `${key}-expanding` }
|
||||
@ -25,7 +34,7 @@ export default (Component) => {
|
||||
expanded={ expanded }
|
||||
onClosed={ () => expandRow.onClosed(key) }
|
||||
>
|
||||
{ expandRow.renderer(props.row) }
|
||||
{ expandRow.renderer(props.row, props.rowIndex) }
|
||||
</ExpandRow> : null
|
||||
];
|
||||
};
|
||||
|
||||
@ -35,6 +35,7 @@ export default class RowAggregator extends shouldUpdater(eventDelegater(React.Co
|
||||
this.props.expanded !== nextProps.expanded ||
|
||||
this.props.expandable !== nextProps.expandable ||
|
||||
this.props.selectable !== nextProps.selectable ||
|
||||
this.props.selectRow.hideSelectColumn !== nextProps.selectRow.hideSelectColumn ||
|
||||
this.shouldUpdatedBySelfProps(nextProps)
|
||||
) {
|
||||
this.shouldUpdateRowContent = this.shouldRowContentUpdate(nextProps);
|
||||
|
||||
@ -3,11 +3,13 @@ import * as selection from './selection';
|
||||
import * as expand from './expand';
|
||||
import * as mutate from './mutate';
|
||||
import * as sort from './sort';
|
||||
import * as type from './type';
|
||||
|
||||
export default {
|
||||
...rows,
|
||||
...selection,
|
||||
...expand,
|
||||
...mutate,
|
||||
...sort
|
||||
...sort,
|
||||
...type
|
||||
};
|
||||
|
||||
18
packages/react-bootstrap-table2/src/store/type.js
vendored
Normal file
18
packages/react-bootstrap-table2/src/store/type.js
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
import Const from '../const';
|
||||
|
||||
export const typeConvert = (type, value) => {
|
||||
if (!type || type === Const.TYPE_STRING) {
|
||||
return String(value);
|
||||
} else if (type === Const.TYPE_NUMBER) {
|
||||
return Number(value);
|
||||
} else if (type === Const.TYPE_BOOLEAN) {
|
||||
if (typeof value === 'boolean') {
|
||||
return value;
|
||||
}
|
||||
return value === 'true';
|
||||
} else if (type === Const.TYPE_DATE) {
|
||||
return new Date(value);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user