File tree 4 files changed +68
-3
lines changed
4 files changed +68
-3
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint max-len: 0 */
2
2
import React from 'react' ;
3
3
import DefaultPaginationTable from './default-pagination-table' ;
4
+ import IconPaginationTable from './icon-pagination-table' ;
4
5
import CustomPaginationTable from './custom-pagination-table' ;
5
6
import PaginationHookTable from './pagination-hook-table' ;
6
7
@@ -17,6 +18,15 @@ class Demo extends React.Component {
17
18
</ div >
18
19
</ div >
19
20
</ div >
21
+ < div className = 'col-md-offset-1 col-md-8' >
22
+ < div className = 'panel panel-default' >
23
+ < div className = 'panel-heading' > Icon Pagination Example</ div >
24
+ < div className = 'panel-body' >
25
+ < h5 > Source in /examples/js/pagination/icon-pagination-table.js</ h5 >
26
+ < IconPaginationTable />
27
+ </ div >
28
+ </ div >
29
+ </ div >
20
30
< div className = 'col-md-offset-1 col-md-8' >
21
31
< div className = 'panel panel-default' >
22
32
< div className = 'panel-heading' > Custom Pagination Example</ div >
Original file line number Diff line number Diff line change
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 ( 70 ) ;
21
+
22
+ export default class IconPaginationTable extends React . Component {
23
+ constructor ( props ) {
24
+ super ( props ) ;
25
+ }
26
+
27
+ render ( ) {
28
+ const tableOptions = {
29
+ prePage : < i className = 'glyphicon glyphicon-chevron-left' /> ,
30
+ nextPage : < i className = 'glyphicon glyphicon-chevron-right' /> ,
31
+ firstPage : < i className = 'glyphicon glyphicon-step-backward' /> ,
32
+ lastPage : < i className = 'glyphicon glyphicon-step-forward' />
33
+ } ;
34
+
35
+ return (
36
+ < div >
37
+ < BootstrapTable
38
+ data = { products }
39
+ options = { tableOptions }
40
+ pagination >
41
+ < TableHeaderColumn dataField = 'id' isKey = { true } > Product ID</ TableHeaderColumn >
42
+ < TableHeaderColumn dataField = 'name' > Product Name</ TableHeaderColumn >
43
+ < TableHeaderColumn dataField = 'price' > Product Price</ TableHeaderColumn >
44
+ </ BootstrapTable >
45
+ </ div >
46
+ ) ;
47
+ }
48
+ }
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class PageButton extends Component {
10
10
11
11
pageBtnClick = e => {
12
12
e . preventDefault ( ) ;
13
- this . props . changePage ( e . currentTarget . textContent ) ;
13
+ this . props . changePage ( this . props . pageNumber ) ;
14
14
}
15
15
16
16
render ( ) {
@@ -33,7 +33,8 @@ PageButton.propTypes = {
33
33
active : PropTypes . bool ,
34
34
disable : PropTypes . bool ,
35
35
hidden : PropTypes . bool ,
36
- children : PropTypes . node
36
+ children : PropTypes . node ,
37
+ pageNumber : PropTypes . number
37
38
} ;
38
39
39
40
export default PageButton ;
Original file line number Diff line number Diff line change @@ -245,23 +245,29 @@ class PaginationList extends Component {
245
245
true :
246
246
false ;
247
247
let title = page + '' ;
248
+ let pageNumber = page ;
248
249
249
250
if ( page === this . props . nextPage ) {
250
251
title = this . props . nextPageTitle ;
252
+ pageNumber = this . props . currPage + 1 ;
251
253
} else if ( page === this . props . prePage ) {
252
254
title = this . props . prePageTitle ;
255
+ pageNumber = this . props . currPage - 1 ;
253
256
} else if ( page === this . props . firstPage ) {
254
257
title = this . props . firstPageTitle ;
258
+ pageNumber = this . props . pageStartIndex ;
255
259
} else if ( page === this . props . lastPage ) {
256
260
title = this . props . lastPageTitle ;
261
+ pageNumber = this . getLastPage ( ) ;
257
262
}
258
263
259
264
return (
260
265
< PageButton key = { index }
261
266
title = { title }
262
267
changePage = { this . changePage }
263
268
active = { isActive }
264
- disable = { isDisabled } >
269
+ disable = { isDisabled }
270
+ pageNumber = { pageNumber } >
265
271
{ page }
266
272
</ PageButton >
267
273
) ;
You can’t perform that action at this time.
0 commit comments