Skip to content

Commit 1afc1f9

Browse files
committed
fix conflicts
2 parents 28b3ea3 + 192a59a commit 1afc1f9

10 files changed

+184
-23
lines changed

dist/react-bootstrap-table.js

+43-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-bootstrap-table.js.map

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-bootstrap-table.min.js

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/js/advance/edit-type-table.js

+28-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@ import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
44

55

66
const jobs = [];
7-
const jobTypes = [ 'A', 'B', 'C', 'D' ];
7+
// editable, select type also accept a string array
8+
// it's most simple case for using select, but the text and value will all be the value in array
9+
// const jobTypes = [ 'A', 'B', 'C', 'D' ];
10+
//
11+
// Following case will be more easy to control the text and value in select.
12+
const jobTypes = [ {
13+
value: 'A',
14+
text: 'TYPE_A'
15+
}, {
16+
value: 'B',
17+
text: 'TYPE_B'
18+
}, {
19+
value: 'C',
20+
text: 'TYPE_C'
21+
}, {
22+
value: 'D',
23+
text: 'TYPE_D'
24+
} ];
825

926
function addJobs(quantity) {
1027
const startId = jobs.length;
@@ -28,12 +45,21 @@ const cellEditProp = {
2845
};
2946

3047
export default class EditTypeTable extends React.Component {
48+
constructor(props) {
49+
super(props);
50+
this.formatType = this.formatType.bind(this);
51+
}
52+
53+
formatType(cell) {
54+
return `TYPE_${cell}`;
55+
}
56+
3157
render() {
3258
return (
3359
<BootstrapTable data={ jobs } cellEdit={ cellEditProp }>
3460
<TableHeaderColumn dataField='id' isKey={ true }>Job ID</TableHeaderColumn>
3561
<TableHeaderColumn dataField='name' editable={ { type: 'textarea' } }>Job Name</TableHeaderColumn>
36-
<TableHeaderColumn dataField='type' editable={ { type: 'select', options: { values: jobTypes } } }>Job Type</TableHeaderColumn>
62+
<TableHeaderColumn dataField='type' dataFormat={ this.formatType } editable={ { type: 'select', options: { values: jobTypes } } }>Job Type</TableHeaderColumn>
3763
<TableHeaderColumn dataField='active' editable={ { type: 'checkbox', options: { values: 'Y:N' } } }>Active</TableHeaderColumn>
3864
<TableHeaderColumn dataField='datetime' editable={ { type: 'datetime' } }>Date Time</TableHeaderColumn>
3965
</BootstrapTable>

examples/js/selection/externally-managed-selection.js

+23-12
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,43 @@ addProducts(100);
2222
export default class ExternallyManagedSelection extends React.Component {
2323
constructor(props) {
2424
super(props);
25+
this.onSelectAll = this.onSelectAll.bind(this);
26+
this.onRowSelect = this.onRowSelect.bind(this);
2527
this.state = {
2628
selected: [],
2729
currPage: 1
2830
};
2931
}
3032

33+
onRowSelect({ id }, isSelected) {
34+
if (isSelected && this.state.selected.length !== 2) {
35+
this.setState({
36+
selected: [ ...this.state.selected, id ].sort(),
37+
currPage: this.refs.table.state.currPage
38+
});
39+
} else {
40+
this.setState({ selected: this.state.selected.filter(it => it !== id) });
41+
}
42+
return false;
43+
}
44+
45+
onSelectAll(isSelected) {
46+
if (!isSelected) {
47+
this.setState({ selected: [] });
48+
}
49+
return false;
50+
}
51+
3152
render() {
3253
const {
3354
currPage
3455
} = this.state;
35-
const onRowSelect = ({ id }, isSelected) => {
36-
if (isSelected && this.state.selected.length !== 2) {
37-
this.setState({
38-
selected: [ ...this.state.selected, id ].sort(),
39-
currPage: this.refs.table.state.currPage
40-
});
41-
} else {
42-
this.setState({ selected: this.state.selected.filter(it => it !== id) });
43-
}
44-
return false;
45-
};
4656

4757
const selectRowProp = {
4858
mode: 'checkbox',
4959
clickToSelect: true,
50-
onSelect: onRowSelect,
60+
onSelect: this.onRowSelect,
61+
onSelectAll: this.onSelectAll,
5162
selected: this.state.selected
5263
};
5364

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* eslint max-len: 0 */
2+
import React from 'react';
3+
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
4+
5+
6+
const products = [];
7+
8+
function addProducts(quantity) {
9+
const startId = products.length;
10+
for (let i = 0; i < quantity; i++) {
11+
const id = startId + i;
12+
products.push({
13+
id: id,
14+
name: 'Item name ' + id,
15+
price: 2100 + i
16+
});
17+
}
18+
}
19+
20+
addProducts(5);
21+
22+
export default class CleanSortedTable extends React.Component {
23+
24+
cleanSort = () => {
25+
this.refs.table.cleanSort();
26+
}
27+
28+
render() {
29+
return (
30+
<div>
31+
<button className='btn btn-default' onClick={ this.cleanSort }>Clean Sort</button>
32+
<BootstrapTable ref='table' data={ products }>
33+
<TableHeaderColumn dataField='id' isKey dataSort>Product ID</TableHeaderColumn>
34+
<TableHeaderColumn dataField='name' dataSort>Product Name</TableHeaderColumn>
35+
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
36+
</BootstrapTable>
37+
</div>
38+
);
39+
}
40+
}

examples/js/sort/demo.js

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import DisableSortIndicatorTable from './disable-sort-indicator-table';
1212
import CustomCaretSortTable from './custom-caret-sort-table';
1313
import ExternalMultiSort from './manage-multi-sort-external-table';
1414
import DefaultASCSortTable from './default-asc-sort-table';
15+
import CleanSortedTable from './clean-sorted-table';
1516

1617
class Demo extends React.Component {
1718
render() {
@@ -125,6 +126,15 @@ class Demo extends React.Component {
125126
</div>
126127
</div>
127128
</div>
129+
<div className='col-md-offset-1 col-md-8'>
130+
<div className='panel panel-default'>
131+
<div className='panel-heading'>Clean Sorted Table</div>
132+
<div className='panel-body'>
133+
<h5>Source in /examples/js/sort/clean-sorted-table.js</h5>
134+
<CleanSortedTable />
135+
</div>
136+
</div>
137+
</div>
128138
</div>
129139
);
130140
}

src/BootstrapTable.js

+7
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,13 @@ class BootstrapTable extends Component {
480480
});
481481
}
482482

483+
cleanSort() {
484+
this.store.cleanSortInfo();
485+
this.setState({
486+
reset: false
487+
});
488+
}
489+
483490
handleSort = (order, sortField) => {
484491
if (this.props.options.onSortChange) {
485492
this.props.options.onSortChange(sortField, order, this.props);

src/Editor.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,18 @@ const editor = function(editable, attr, format, editorClass, defaultValue, ignor
3737
let options = [];
3838
const values = editable.options.values;
3939
if (Array.isArray(values)) {// only can use arrray data for options
40-
let rowValue;
41-
options = values.map((d, i) => {
42-
rowValue = format ? format(d) : d;
40+
let text;
41+
let value;
42+
options = values.map((option, i) => {
43+
if (typeof option === 'object') {
44+
text = option.text;
45+
value = option.value;
46+
} else {
47+
text = format ? format(option) : option;
48+
value = option;
49+
}
4350
return (
44-
<option key={ 'option' + i } value={ d }>{ rowValue }</option>
51+
<option key={ 'option' + i } value={ value }>{ text }</option>
4552
);
4653
});
4754
}

src/store/TableDataStore.js

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ export class TableDataStore {
115115
}
116116
}
117117

118+
cleanSortInfo() {
119+
this.sortList = [];
120+
}
121+
118122
setSelectedRowKey(selectedRowKeys) {
119123
this.selected = selectedRowKeys;
120124
}

0 commit comments

Comments
 (0)