Compare commits

..

7 Commits

Author SHA1 Message Date
AllenFang
be916d81a3 Publish
- react-bootstrap-table2-example@1.0.32
 - react-bootstrap-table-next@3.2.1
2019-09-30 13:04:37 +08:00
Allen
49d1ce8812 Merge pull request #1109 from react-bootstrap-table/develop
20190929 release
2019-09-30 13:01:54 +08:00
AllenFang
18caf0ac8d try to fix #1085 and #1098 2019-09-29 16:36:32 +08:00
AllenFang
1b9bd63370 fix #1104 2019-09-29 16:30:49 +08:00
AllenFang
b2121fdf24 fix #1099 #1101 2019-09-29 16:19:36 +08:00
AllenFang
4aaf140de5 fix wrong story code 2019-09-29 15:06:11 +08:00
ebfg
569aa0195e Note in defaultSorted docs that only one column is supported. #1083 (#1088) 2019-09-15 14:36:10 +08:00
7 changed files with 19 additions and 11 deletions

View File

@@ -208,6 +208,8 @@ const defaultSorted = [{
}];
```
**Note**: Only the first column is sorted currently, see #1083.
### <a name='defaultSortDirection'>defaultSortDirection - [String]</a>
Default sort direction when user click on header column at first time, available value is `asc` and `desc`. Default is `desc`.

View File

@@ -36,11 +36,12 @@ const columns = [{
const MyExportCSV = (props) => {
const handleClick = () => {
props.onExport();
// passing my custom data
props.onExport(products.filter(r => r.id > 2));
};
return (
<div>
<button className="btn btn-success" onClick={ handleClick }>Export to CSV</button>
<button className="btn btn-success" onClick={ handleClick }>Only export Product ID bigger than 2</button>
</div>
);
};

View File

@@ -1,6 +1,6 @@
{
"name": "react-bootstrap-table2-example",
"version": "1.0.31",
"version": "1.0.32",
"description": "",
"main": "index.js",
"private": true,

View File

@@ -1,6 +1,6 @@
{
"name": "react-bootstrap-table-next",
"version": "3.2.0",
"version": "3.2.1",
"description": "Next generation of react-bootstrap-table",
"main": "./lib/index.js",
"repository": {

View File

@@ -3,6 +3,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import Const from '../const';
import _ from '../utils';
import dataOperator from '../store/operators';
import { getSelectionSummary } from '../store/selection';
@@ -72,7 +73,7 @@ class SelectionProvider extends React.Component {
if (!isUnSelect) {
currSelected = selected.concat(dataOperator.selectableKeys(data, keyField, nonSelectable));
} else {
currSelected = selected.filter(s => typeof data.find(d => d[keyField] === s) === 'undefined');
currSelected = selected.filter(s => typeof data.find(d => _.get(d, keyField) === s) === 'undefined');
}
let result;

View File

@@ -43,10 +43,14 @@ class HeaderCell extends eventDelegater(React.Component) {
const delegateEvents = this.delegate(headerEvents);
const customAttrs = _.isFunction(headerAttrs)
? headerAttrs(column, index)
: (headerAttrs || {});
const cellAttrs = {
..._.isFunction(headerAttrs) ? headerAttrs(column, index) : headerAttrs,
...customAttrs,
...delegateEvents,
tabIndex: 0
tabIndex: _.isDefined(customAttrs.tabIndex) ? customAttrs.tabIndex : 0
};
let sortSymbol;

View File

@@ -2,14 +2,14 @@ import _ from '../utils';
import { getRowByRowId } from './rows';
export const getSelectionSummary = (
data,
data = [],
keyField,
selected = []
) => {
let allRowsSelected = data.length > 0;
let allRowsNotSelected = true;
const rowKeys = data.map(d => d[keyField]);
const rowKeys = data.map(d => _.get(d, keyField));
for (let i = 0; i < rowKeys.length; i += 1) {
const curr = rowKeys[i];
if (typeof selected.find(x => x === curr) === 'undefined') {
@@ -24,7 +24,7 @@ export const getSelectionSummary = (
};
};
export const selectableKeys = (data, keyField, skips = []) => {
export const selectableKeys = (data = [], keyField, skips = []) => {
if (skips.length === 0) {
return data.map(row => _.get(row, keyField));
}
@@ -40,6 +40,6 @@ export const unSelectableKeys = (selected, skips = []) => {
return selected.filter(x => _.contains(skips, x));
};
export const getSelectedRows = (data, keyField, selected) =>
export const getSelectedRows = (data = [], keyField, selected) =>
selected.map(k => getRowByRowId(data, keyField, k)).filter(x => !!x);