-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
492 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
import React from 'react'; | ||
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table'; | ||
|
||
|
||
var products = []; | ||
|
||
function addProducts(quantity) { | ||
var startId = products.length; | ||
for (var i = 0; i < quantity; i++) { | ||
var id = startId + i; | ||
products.push({ | ||
id: id, | ||
name: "Item name " + id, | ||
price: 2100 + i | ||
}); | ||
} | ||
} | ||
|
||
addProducts(70); | ||
|
||
export default class PaginationHookTable extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
page: undefined, | ||
sizePerPage: undefined, | ||
}; | ||
|
||
this.options = { | ||
onPageChange: this.onPageChange.bind(this), | ||
}; | ||
} | ||
|
||
onPageChange(page, sizePerPage) { | ||
this.setState({ | ||
page, | ||
sizePerPage, | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<p style={{color: 'red'}}>pagination: page={this.state.page}, sizePerPage={this.state.sizePerPage}</p> | ||
<BootstrapTable | ||
data={products} | ||
pagination | ||
options={this.options} | ||
> | ||
<TableHeaderColumn dataField="id" isKey={true}>Product ID</TableHeaderColumn> | ||
<TableHeaderColumn dataField="name">Product Name</TableHeaderColumn> | ||
<TableHeaderColumn dataField="price">Product Price</TableHeaderColumn> | ||
</BootstrapTable> | ||
</div> | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict'; | ||
import React from 'react'; | ||
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table'; | ||
|
||
|
||
var products = []; | ||
|
||
function addProducts(quantity) { | ||
var startId = products.length; | ||
for (var i = 0; i < quantity; i++) { | ||
var id = startId + i; | ||
products.push({ | ||
id: id, | ||
name: "Item name " + id, | ||
price: 100 + i | ||
}); | ||
} | ||
} | ||
|
||
addProducts(5); | ||
|
||
export default class SortHookTable extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
page: undefined, | ||
sizePerPage: undefined, | ||
sortName: undefined, | ||
sortOrder: undefined, | ||
}; | ||
|
||
this.options = { | ||
sortName: "name", //default sort column name | ||
sortOrder: "desc", //default sort order | ||
onSortChange: this.onSortChange.bind(this), | ||
}; | ||
} | ||
|
||
onSortChange(sortName, sortOrder) { | ||
console.info('onSortChange', arguments); | ||
this.setState({ | ||
sortName, | ||
sortOrder, | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<p style={{color: 'red'}}>sort: sortName={this.state.sortName}, sortOrder={this.state.sortOrder}</p> | ||
<BootstrapTable data={products} options={this.options}> | ||
<TableHeaderColumn dataField="id" isKey={true} dataSort={true}>Product ID</TableHeaderColumn> | ||
<TableHeaderColumn dataField="name" dataSort={true}>Product Name</TableHeaderColumn> | ||
<TableHeaderColumn dataField="price">Product Price</TableHeaderColumn> | ||
</BootstrapTable> | ||
</div> | ||
); | ||
} | ||
}; |
Oops, something went wrong.