File tree Expand file tree Collapse file tree 4 files changed +68
-3
lines changed
Expand file tree Collapse file tree 4 files changed +68
-3
lines changed Original file line number Diff line number Diff line change 11/* eslint max-len: 0 */
22import React from 'react' ;
33import DefaultPaginationTable from './default-pagination-table' ;
4+ import IconPaginationTable from './icon-pagination-table' ;
45import CustomPaginationTable from './custom-pagination-table' ;
56import PaginationHookTable from './pagination-hook-table' ;
67
@@ -17,6 +18,15 @@ class Demo extends React.Component {
1718 </ div >
1819 </ div >
1920 </ 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 >
2030 < div className = 'col-md-offset-1 col-md-8' >
2131 < div className = 'panel panel-default' >
2232 < 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 {
1010
1111 pageBtnClick = e => {
1212 e . preventDefault ( ) ;
13- this . props . changePage ( e . currentTarget . textContent ) ;
13+ this . props . changePage ( this . props . pageNumber ) ;
1414 }
1515
1616 render ( ) {
@@ -33,7 +33,8 @@ PageButton.propTypes = {
3333 active : PropTypes . bool ,
3434 disable : PropTypes . bool ,
3535 hidden : PropTypes . bool ,
36- children : PropTypes . node
36+ children : PropTypes . node ,
37+ pageNumber : PropTypes . number
3738} ;
3839
3940export default PageButton ;
Original file line number Diff line number Diff line change @@ -229,23 +229,29 @@ class PaginationList extends Component {
229229 true :
230230 false ;
231231 let title = page + '' ;
232+ let pageNumber = page ;
232233
233234 if ( page === this . props . nextPage ) {
234235 title = this . props . nextPageTitle ;
236+ pageNumber = this . props . currPage + 1 ;
235237 } else if ( page === this . props . prePage ) {
236238 title = this . props . prePageTitle ;
239+ pageNumber = this . props . currPage - 1 ;
237240 } else if ( page === this . props . firstPage ) {
238241 title = this . props . firstPageTitle ;
242+ pageNumber = this . props . pageStartIndex ;
239243 } else if ( page === this . props . lastPage ) {
240244 title = this . props . lastPageTitle ;
245+ pageNumber = this . getLastPage ( ) ;
241246 }
242247
243248 return (
244249 < PageButton key = { index }
245250 title = { title }
246251 changePage = { this . changePage }
247252 active = { isActive }
248- disable = { isDisabled } >
253+ disable = { isDisabled }
254+ pageNumber = { pageNumber } >
249255 { page }
250256 </ PageButton >
251257 ) ;
You can’t perform that action at this time.
0 commit comments