Skip to content

Instantly share code, notes, and snippets.

View AllenFang's full-sized avatar
🇹🇼

allen AllenFang

🇹🇼
View GitHub Profile
satisfaction = [ 0, 1, 2, 3, 4, 5 ];
class NumberOptionsFilterWithDefaultValue extends React.Component {
render() {
return (
<BootstrapTable data={ products }>
<TableHeaderColumn dataField='id' isKey>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='satisfaction'
filter={ { type: 'NumberFilter', options: satisfaction, defaultValue: { number: 3, comparator: '>=' } } }>Buyer Satisfaction</TableHeaderColumn>
// const startDate = new Date(2015, 0, 1);
// const endDate = new Date();
// new Date(startDate.getTime() + Math.random() * (endDate.getTime() - startDate.getTime()));
function dateFormatter(cell, row) {
return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`;
}
class DateFilter extends React.Component {
render() {
// const startDate = new Date(2015, 0, 1);
// const endDate = new Date();
// new Date(startDate.getTime() + Math.random() * (endDate.getTime() - startDate.getTime()));
function dateFormatter(cell, row) {
return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`;
}
class DateFilter extends React.Component {
render() {
// const startDate = new Date(2015, 0, 1);
// const endDate = new Date();
// new Date(startDate.getTime() + Math.random() * (endDate.getTime() - startDate.getTime()));
function dateFormatter(cell, row) {
return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`;
}
class ProgrammaticallyDateFilter extends React.Component {
class CheckboxFilter extends React.Component {
constructor(props) {
super(props);
this.filter = this.filter.bind(this);
this.isFiltered = this.isFiltered.bind(this);
}
filter(event) {
if (this.refs.nokCheckbox.checked && this.refs.okCheckbox.checked) {
function formatFloat(cell, row) {
return parseFloat(cell);
}
class FloatFilter extends React.Component {
render() {
return (
<BootstrapTable data={ products }>
<TableHeaderColumn dataField='id' isKey>Product ID</TableHeaderColumn>
const qualityType = {
0: 'good',
1: 'bad',
2: 'unknown'
};
function enumFormatter(cell, row, enumObject) {
return enumObject[cell];
}
const selectRowProp = {
mode: 'radio'
};
class SingleSelectTable extends React.Component {
render() {
return (
<BootstrapTable data={ products } selectRow={ selectRowProp }>
<TableHeaderColumn dataField='id'>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
const selectRowProp = {
mode: 'checkbox'
};
class MultiSelectTable extends React.Component {
render() {
return (
<BootstrapTable data={ products } selectRow={ selectRowProp }>
<TableHeaderColumn dataField='id' isKey>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
const selectRowProp = {
mode: 'checkbox',
clickToSelect: true,
unselectable: [ 1, 3 ] // give rowkeys for unselectable row
};
class UnSelectableTable extends React.Component {
render() {
return (
<BootstrapTable data={ products } selectRow={ selectRowProp }>