Skip to content

Commit 546bdb7

Browse files
committed
Follow up on PR AllenFang#418
rebased the code on latest master added support for search updated example to show filtering and search
1 parent 4e76e13 commit 546bdb7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

examples/js/custom-data-access/custom-data-access.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function addProducts(quantity) {
1515
price: 2100 + i,
1616
category: {
1717
id: 20 + i,
18-
name: 'Category name ' + i
18+
name: 'Category name ' + (quantity + i)
1919
}
2020
});
2121
}
@@ -30,10 +30,10 @@ function categoryName(product) {
3030
export default class TrClassStringTable extends React.Component {
3131
render() {
3232
return (
33-
<BootstrapTable data={ products }>
33+
<BootstrapTable data={ products } search={ true } >
3434
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
3535
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
36-
<TableHeaderColumn dataField='price' dataAccess={ categoryName }>Category name</TableHeaderColumn>
36+
<TableHeaderColumn dataField='price' dataAccess={ categoryName } filter={ { type: 'TextFilter' } }>Category name</TableHeaderColumn>
3737
</BootstrapTable>
3838
);
3939
}

src/store/TableDataStore.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ export class TableDataStore {
427427
if (this.colInfos[key]) {
428428
const { format, filterFormatted, formatExtraData } = this.colInfos[key];
429429
if (filterFormatted && format) {
430-
targetVal = format(row[key], row, formatExtraData);
430+
targetVal = format(targetVal, row, formatExtraData);
431431
}
432432
}
433433

@@ -480,7 +480,9 @@ export class TableDataStore {
480480
const key = keys[i];
481481
if (this.colInfos[key] && row[key]) {
482482
const { format, filterFormatted, formatExtraData, searchable } = this.colInfos[key];
483-
let targetVal = row[key];
483+
let targetVal = typeof this.colInfos[key].dataAccess === 'function' ?
484+
this.colInfos[key].dataAccess(row) :
485+
row[key];
484486
if (searchable) {
485487
if (filterFormatted && format) {
486488
targetVal = format(targetVal, row, formatExtraData);

0 commit comments

Comments
 (0)