File tree 2 files changed +69
-0
lines changed
2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 2
2
import React from 'react' ;
3
3
import SortTable from './sort-table' ;
4
4
import DefaultSortTable from './default-sort-table' ;
5
+ import ExternalSort from './manage-sort-external-table' ;
5
6
import CustomSortTable from './custom-sort-table' ;
6
7
import CustomSortWithExtraDataTable from './custom-sort-with-extra-data-table' ;
7
8
import ReusableCustomSortTable from './reusable-custom-sort-table' ;
@@ -31,6 +32,15 @@ class Demo extends React.Component {
31
32
</ div >
32
33
</ div >
33
34
</ div >
35
+ < div className = 'col-md-offset-1 col-md-8' >
36
+ < div className = 'panel panel-default' >
37
+ < div className = 'panel-heading' > Manage Sorting Externally Example</ div >
38
+ < div className = 'panel-body' >
39
+ < h5 > Source in /examples/js/sort/manage-sort-external-table.js</ h5 >
40
+ < ExternalSort />
41
+ </ div >
42
+ </ div >
43
+ </ div >
34
44
< div className = 'col-md-offset-1 col-md-8' >
35
45
< div className = 'panel panel-default' >
36
46
< div className = 'panel-heading' > Customize Table Sort Example</ div >
Original file line number Diff line number Diff line change
1
+ /* eslint max-len: 0 */
2
+ /* eslint no-console: 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
+ addProducts ( 5 ) ;
22
+
23
+ export default class ExternalSort extends React . Component {
24
+ constructor ( props ) {
25
+ super ( props ) ;
26
+
27
+ this . state = {
28
+ sortName : undefined ,
29
+ sortOrder : undefined
30
+ } ;
31
+ this . onSortChange = this . onSortChange . bind ( this ) ;
32
+ }
33
+
34
+ onSortChange ( sortName , sortOrder ) {
35
+ console . info ( 'onSortChange' , arguments ) ;
36
+ this . setState ( {
37
+ sortName,
38
+ sortOrder
39
+ } ) ;
40
+ }
41
+
42
+ render ( ) {
43
+ const options = {
44
+ sortName : this . state . sortName ,
45
+ sortOrder : this . state . sortOrder ,
46
+ onSortChange : this . onSortChange
47
+ } ;
48
+ return (
49
+ < div >
50
+ < p style = { { color : 'red' } } > sort: sortName={ this . state . sortName } , sortOrder={ this . state . sortOrder } </ p >
51
+ < BootstrapTable data = { products } options = { options } >
52
+ < TableHeaderColumn dataField = 'id' isKey = { true } dataSort = { true } > Product ID</ TableHeaderColumn >
53
+ < TableHeaderColumn dataField = 'name' dataSort = { true } > Product Name</ TableHeaderColumn >
54
+ < TableHeaderColumn dataField = 'price' > Product Price</ TableHeaderColumn >
55
+ </ BootstrapTable >
56
+ </ div >
57
+ ) ;
58
+ }
59
+ }
You can’t perform that action at this time.
0 commit comments