Skip to content

Commit 7057758

Browse files
committed
fix conflicts
2 parents 3017388 + 93829cd commit 7057758

12 files changed

+5408
-51
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
<a name="v3.4.5"></a>
2+
# [v3.4.5](https://github.com/AllenFang/react-bootstrap-table/compare/v3.4.4...v3.4.5) (2017-07-13)
3+
## Bug fixes
4+
* Fix [#1410](https://github.com/AllenFang/react-bootstrap-table/issues/1410) again([3f60275](https://github.com/AllenFang/react-bootstrap-table/commit/3f602755721529471ba5d5fa36ed2930d19dfbf5))
5+
6+
## Enhancement
7+
* Pass `rowIndex` as third argument for `options.onRowClick`([4b5ba03](https://github.com/AllenFang/react-bootstrap-table/commit/4b5ba037437977b54a577084e0779f53e9b02785))
8+
9+
## Features
10+
* Able to disable the `tabIndex` via `withoutTabIndex` on `BootstrapTable`([ce6f744](https://github.com/AllenFang/react-bootstrap-table/commit/ce6f744d3d7f101c800459a7d0608daed5dff74e))
11+
12+
<a name="v3.4.4"></a>
13+
# [v3.4.4](https://github.com/AllenFang/react-bootstrap-table/compare/v3.4.3...v3.4.4) (2017-07-09)
14+
## Bug fixes
15+
* Pass row object as second argument for `editable.validator` when calling by insert row([5ede872](https://github.com/AllenFang/react-bootstrap-table/commit/5ede87270677c9d8fe37bdef2cccbf4a05f5748a))
16+
* Fix text filter is not updated when rerender([298e971](https://github.com/AllenFang/react-bootstrap-table/commit/298e971b5c5658d0baeb67163d279298751085ed))
17+
* Fix wrong colspan on a empty table when hide seleciton column([62ceb31](https://github.com/AllenFang/react-bootstrap-table/commit/62ceb313f6d523e02f5b49275b69b3b4e3326e7a))
18+
19+
## Enhancement
20+
* return `false` will render default editor in insert model for the hook function of [customInsertEditor.getElement](http://allenfang.github.io/react-bootstrap-table/custom.html#insertmodalfield)([f2382b3](https://github.com/AllenFang/react-bootstrap-table/commit/f2382b36cc924e286ec271f92134673278458c3c))
21+
122
<a name="v3.4.3"></a>
223
# [v3.4.3](https://github.com/AllenFang/react-bootstrap-table/compare/v3.4.2...v3.4.3) (2017-07-05)
324
## Bug fixes

dist/react-bootstrap-table.js

Lines changed: 5260 additions & 20 deletions
Large diffs are not rendered by default.

dist/react-bootstrap-table.js.map

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-bootstrap-table.min.js

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/js/selection/row-click-table.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ function addProducts(quantity) {
1818
}
1919
}
2020

21-
addProducts(5);
21+
addProducts(50);
2222

2323
const options = {
24-
onRowClick: function(row, columnIndex) {
25-
alert(`You click row id: ${row.id}, column index: ${columnIndex}`);
24+
onRowClick: function(row, columnIndex, rowIndex) {
25+
alert(`You click row id: ${row.id}, column index: ${columnIndex}, row index: ${rowIndex}`);
2626
},
2727
onRowDoubleClick: function(row) {
2828
alert(`You double click row id: ${row.id}`);
@@ -32,7 +32,7 @@ const options = {
3232
export default class SingleSelectTable extends React.Component {
3333
render() {
3434
return (
35-
<BootstrapTable data={ products } options={ options }>
35+
<BootstrapTable data={ products } options={ options } pagination>
3636
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
3737
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
3838
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>

examples/js/style/demo.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ require('./style.css');
33
import React from 'react';
44
import TrClassStringTable from './tr-class-string-table';
55
import TrClassFunctionTable from './tr-class-function-table';
6+
import TrStyleTable from './tr-style-table';
67
import TdClassStringTable from './td-class-string-table';
78
import TdClassFunctionTable from './td-class-function-table';
89
import EditTdClassTable from './edit-td-class-table';
@@ -41,6 +42,15 @@ class Demo extends React.Component {
4142
</div>
4243
</div>
4344
</div>
45+
<div className='col-md-offset-1 col-md-8'>
46+
<div className='panel panel-default'>
47+
<div className='panel-heading'>Set String or Function for <code>trStyle</code> on &lt;BootstrapTable&gt;</div>
48+
<div className='panel-body'>
49+
<h5>Source in /examples/js/style/tr-style-table.js</h5>
50+
<TrStyleTable />
51+
</div>
52+
</div>
53+
</div>
4454
<div className='col-md-offset-1 col-md-8'>
4555
<div className='panel panel-default'>
4656
<div className='panel-heading'>Set String as <code>classname</code> & <code>columnClassName</code> on &lt;TableHeaderColumn&gt;(header &amp; column)</div>

examples/js/style/tr-style-table.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* eslint max-len: 0 */
2+
/* eslint no-unused-vars: 0 */
3+
import React from 'react';
4+
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
5+
6+
7+
const products = [];
8+
9+
function addProducts(quantity) {
10+
const startId = products.length;
11+
for (let i = 0; i < quantity; i++) {
12+
const id = startId + i;
13+
products.push({
14+
id: id,
15+
name: 'Item name ' + id,
16+
price: 2100 + i
17+
});
18+
}
19+
}
20+
21+
22+
addProducts(5);
23+
24+
export default class TrClassStringTable extends React.Component {
25+
26+
trStyle = (row, rowIndex) => {
27+
return { backgroundColor: '#FFFAFA' };
28+
}
29+
30+
render() {
31+
const selectRow = { mode: 'checkbox', bgColor: 'red' };
32+
return (
33+
<BootstrapTable data={ products } trStyle={ this.trStyle } selectRow={ selectRow }>
34+
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
35+
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
36+
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
37+
</BootstrapTable>
38+
);
39+
}
40+
}

src/BootstrapTable.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class BootstrapTable extends Component {
2020
constructor(props) {
2121
super(props);
2222
this.isIE = false;
23-
this._attachCellEditFunc();
2423
if (Util.canUseDOM()) {
2524
this.isIE = document.documentMode;
2625
}
@@ -217,6 +216,9 @@ class BootstrapTable extends Component {
217216
let { replace } = nextProps;
218217
replace = replace || this.props.replace;
219218

219+
if (!nextProps.data) {
220+
return;
221+
}
220222
this.store.setData(nextProps.data.slice());
221223

222224
if (!replace) {
@@ -325,22 +327,11 @@ class BootstrapTable extends Component {
325327

326328
componentDidUpdate() {
327329
this._adjustTable();
328-
this._attachCellEditFunc();
329330
if (this.props.options.afterTableComplete) {
330331
this.props.options.afterTableComplete();
331332
}
332333
}
333334

334-
_attachCellEditFunc() {
335-
const { cellEdit } = this.props;
336-
if (cellEdit) {
337-
this.props.cellEdit.__onCompleteEdit__ = this.handleEditCell.bind(this);
338-
if (cellEdit.mode !== Const.CELL_EDIT_NONE) {
339-
this.props.selectRow.clickToSelect = false;
340-
}
341-
}
342-
}
343-
344335
/**
345336
* Returns true if in the current configuration,
346337
* the datagrid should load its data remotely.
@@ -393,6 +384,10 @@ class BootstrapTable extends Component {
393384
const { paginationPosition = Const.PAGINATION_POS_BOTTOM } = this.props.options;
394385
const showPaginationOnTop = paginationPosition !== Const.PAGINATION_POS_BOTTOM;
395386
const showPaginationOnBottom = paginationPosition !== Const.PAGINATION_POS_TOP;
387+
const selectRow = { ...this.props.selectRow };
388+
if (this.props.cellEdit && this.props.cellEdit.mode !== Const.CELL_EDIT_NONE) {
389+
selectRow.clickToSelect = false;
390+
}
396391

397392
return (
398393
<div className={ classSet('react-bs-table-container', this.props.className, this.props.containerClass) }
@@ -440,12 +435,13 @@ class BootstrapTable extends Component {
440435
expandParentClass={ this.props.options.expandParentClass }
441436
columns={ columns }
442437
trClassName={ this.props.trClassName }
438+
trStyle={ this.props.trStyle }
443439
striped={ this.props.striped }
444440
bordered={ this.props.bordered }
445441
hover={ this.props.hover }
446442
keyField={ this.store.getKeyField() }
447443
condensed={ this.props.condensed }
448-
selectRow={ this.props.selectRow }
444+
selectRow={ selectRow }
449445
expandColumnOptions={ this.props.expandColumnOptions }
450446
cellEdit={ this.props.cellEdit }
451447
selectedRowKeys={ this.state.selectedRowKeys }
@@ -463,7 +459,9 @@ class BootstrapTable extends Component {
463459
keyBoardNav={ this.props.keyBoardNav }
464460
onNavigateCell={ this.handleNavigateCell }
465461
x={ this.state.x }
466-
y={ this.state.y } />
462+
y={ this.state.y }
463+
withoutTabIndex={ this.props.withoutTabIndex }
464+
onEditCell={ this.handleEditCell } />
467465
</div>
468466
{ tableFilter }
469467
{ showPaginationOnBottom ? pagination : null }
@@ -665,7 +663,7 @@ class BootstrapTable extends Component {
665663
handleRowClick = (row, rowIndex, columnIndex) => {
666664
const { options, keyBoardNav } = this.props;
667665
if (options.onRowClick) {
668-
options.onRowClick(row, columnIndex);
666+
options.onRowClick(row, columnIndex, rowIndex);
669667
}
670668
if (keyBoardNav) {
671669
let { clickToNav } = typeof keyBoardNav === 'object' ? keyBoardNav : {};
@@ -791,7 +789,7 @@ class BootstrapTable extends Component {
791789
}
792790
}
793791

794-
handleEditCell(newVal, rowIndex, colIndex) {
792+
handleEditCell = (newVal, rowIndex, colIndex) => {
795793
const { beforeSaveCell } = this.props.cellEdit;
796794
const columns = this.getColumnsDescription(this.props);
797795
const fieldName = columns[colIndex].name;
@@ -1076,7 +1074,7 @@ class BootstrapTable extends Component {
10761074
csvFileName = csvFileName();
10771075
}
10781076

1079-
exportCSVUtil(result, keys, csvFileName, separator, noAutoBOM || true, excludeCSVHeader);
1077+
exportCSVUtil(result, keys, csvFileName, separator, noAutoBOM, excludeCSVHeader);
10801078
}
10811079

10821080
handleSearch = searchText => {
@@ -1441,6 +1439,7 @@ BootstrapTable.propTypes = {
14411439
condensed: PropTypes.bool,
14421440
pagination: PropTypes.bool,
14431441
printable: PropTypes.bool,
1442+
withoutTabIndex: PropTypes.bool,
14441443
keyBoardNav: PropTypes.oneOfType([ PropTypes.bool, PropTypes.object ]),
14451444
searchPlaceholder: PropTypes.string,
14461445
selectRow: PropTypes.shape({
@@ -1477,6 +1476,7 @@ BootstrapTable.propTypes = {
14771476
strictSearch: PropTypes.bool,
14781477
columnFilter: PropTypes.bool,
14791478
trClassName: PropTypes.any,
1479+
trStyle: PropTypes.any,
14801480
tableStyle: PropTypes.object,
14811481
containerStyle: PropTypes.object,
14821482
headerStyle: PropTypes.object,
@@ -1607,6 +1607,7 @@ BootstrapTable.defaultProps = {
16071607
condensed: false,
16081608
pagination: false,
16091609
printable: false,
1610+
withoutTabIndex: false,
16101611
keyBoardNav: false,
16111612
searchPlaceholder: undefined,
16121613
selectRow: {
@@ -1639,6 +1640,7 @@ BootstrapTable.defaultProps = {
16391640
multiColumnSort: 1,
16401641
columnFilter: false,
16411642
trClassName: '',
1643+
trStyle: undefined,
16421644
tableStyle: undefined,
16431645
containerStyle: undefined,
16441646
headerStyle: undefined,

src/TableBody.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TableBody extends Component {
1717
}
1818

1919
render() {
20-
const { cellEdit, beforeShowError, x, y, keyBoardNav } = this.props;
20+
const { cellEdit, beforeShowError, x, y, keyBoardNav, trStyle } = this.props;
2121
const tableClasses = classSet('table', {
2222
'table-striped': this.props.striped,
2323
'table-bordered': this.props.bordered,
@@ -128,7 +128,8 @@ class TableBody extends Component {
128128
keyBoardNav={ enableKeyBoardNav }
129129
onKeyDown={ this.handleCellKeyDown }
130130
customNavStyle={ customNavStyle }
131-
row={ data }>
131+
row={ data }
132+
withoutTabIndex={ this.props.withoutTabIndex }>
132133
{ columnChild }
133134
</TableColumn>
134135
);
@@ -168,7 +169,8 @@ class TableBody extends Component {
168169
onRowMouseOut={ this.handleRowMouseOut }
169170
onSelectRow={ this.handleSelectRow }
170171
onExpandRow={ this.handleClickCell }
171-
unselectableRow={ disable }>
172+
unselectableRow={ disable }
173+
style={ trStyle }>
172174
{ this.props.expandColumnOptions.expandColumnVisible &&
173175
this.props.expandColumnOptions.expandColumnBeforeSelectColumn &&
174176
expandedRowColumn }
@@ -204,7 +206,7 @@ class TableBody extends Component {
204206
+ ((isSelectRowDefined && !this.props.selectRow.hideSelectColumn) ? 1 : 0)
205207
+ (this.props.expandColumnOptions.expandColumnVisible ? 1 : 0);
206208
tableRows = [
207-
<TableRow key='##table-empty##'>
209+
<TableRow key='##table-empty##' style={ trStyle }>
208210
<td data-toggle='collapse'
209211
colSpan={ colSpan }
210212
className='react-bs-table-no-data'>
@@ -422,7 +424,7 @@ class TableBody extends Component {
422424

423425
handleCompleteEditCell = (newVal, rowIndex, columnIndex) => {
424426
if (newVal !== null) {
425-
const result = this.props.cellEdit.__onCompleteEdit__(newVal, rowIndex, columnIndex);
427+
const result = this.props.onEditCell(newVal, rowIndex, columnIndex);
426428
if (result !== Const.AWAIT_BEFORE_CELL_EDIT) {
427429
this.setState(() => { return { currEditCell: null }; });
428430
}
@@ -527,6 +529,7 @@ TableBody.propTypes = {
527529
keyBoardNav: PropTypes.oneOfType([ PropTypes.bool, PropTypes.object ]),
528530
x: PropTypes.number,
529531
y: PropTypes.number,
530-
onNavigateCell: PropTypes.func
532+
onNavigateCell: PropTypes.func,
533+
withoutTabIndex: PropTypes.bool
531534
};
532535
export default TableBody;

src/TableColumn.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class TableColumn extends Component {
109109
keyBoardNav,
110110
tabIndex,
111111
customNavStyle,
112+
withoutTabIndex,
112113
row
113114
} = this.props;
114115

@@ -148,8 +149,11 @@ class TableColumn extends Component {
148149
className = `${className} default-focus-cell`;
149150
}
150151
}
152+
153+
const attr = {};
154+
if (!withoutTabIndex) attr.tabIndex = tabIndex;
151155
return (
152-
<td tabIndex={ tabIndex } style={ tdStyle }
156+
<td { ...attr } style={ tdStyle }
153157
title={ columnTitle }
154158
className={ className }
155159
{ ...opts } { ...attrs }>
@@ -171,13 +175,15 @@ TableColumn.propTypes = {
171175
isFocus: PropTypes.bool,
172176
onKeyDown: PropTypes.func,
173177
tabIndex: PropTypes.string,
178+
withoutTabIndex: PropTypes.bool,
174179
keyBoardNav: PropTypes.oneOfType([ PropTypes.bool, PropTypes.object ]),
175180
customNavStyle: PropTypes.oneOfType([ PropTypes.func, PropTypes.object ]),
176181
row: PropTypes.any /* only used on custom styling for navigation */
177182
};
178183

179184
TableColumn.defaultProps = {
180185
dataAlign: 'left',
186+
withoutTabIndex: false,
181187
hidden: false,
182188
className: '',
183189
isFocus: false,

0 commit comments

Comments
 (0)