Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
0ff0c33
upgrade react and react-dom
AllenFang May 13, 2018
906180a
implement context-based container
AllenFang May 13, 2018
6d08a24
implement selection context
AllenFang May 13, 2018
2525465
implement sort context
AllenFang May 13, 2018
143acde
refactoring remote sort
AllenFang May 19, 2018
5307e58
implement data operator
AllenFang May 19, 2018
216bc10
implement celledit context
AllenFang May 19, 2018
4f6809d
fix custom filter value example broken
AllenFang May 20, 2018
2f7d010
add clear all filter story
AllenFang May 20, 2018
8f4dc99
implement filter context
AllenFang May 20, 2018
1e72c80
construct context dynamically
AllenFang May 20, 2018
6c086c3
implement pagination context
AllenFang May 20, 2018
4ecf243
no more state anti-pattern
AllenFang May 20, 2018
d534c42
change to partial selection when pagination enabled
AllenFang May 20, 2018
b1c086f
fix cache context issue
AllenFang May 20, 2018
400c307
refine remote method
AllenFang May 20, 2018
74bf885
remove useless code
AllenFang May 23, 2018
fc0b99e
patch tests for react-bootstrap-table-next
AllenFang May 28, 2018
167352f
fix selectRow doesnt pass to CellEditContext
AllenFang May 30, 2018
c13b3fa
patch test for editor, filter, pagination
AllenFang Jun 2, 2018
9c677fe
enhance remote all example
AllenFang Jun 15, 2018
78ea630
fix bug for default sort and filter have potential issue when remote …
AllenFang Jun 15, 2018
77301c2
implement table search
AllenFang Jun 18, 2018
760d459
add example for tble search
AllenFang Jun 18, 2018
0d4d32c
patch for remote cell edit
AllenFang Jun 23, 2018
7b15bf4
patch tests for search
AllenFang Jun 23, 2018
18b785d
update peer dependencies for react react-dom
AllenFang Jun 23, 2018
46f0ce4
prepare builds for react-bootstrap-table2-toolkit
AllenFang Jun 23, 2018
6eaffe1
patch docs for table search
AllenFang Jun 23, 2018
35b1e37
implement expand row sketch
AllenFang Jun 24, 2018
dbd0f89
add stories for expand row
AllenFang Jun 24, 2018
4af5b4f
implement expand indicator
AllenFang Jul 1, 2018
81ddd2c
add stories for expand indicator
AllenFang Jul 1, 2018
c36aa24
fix filter context tests broken due to missing onExternalFilter
AllenFang Jul 1, 2018
a18932e
patch docs for expand row
AllenFang Jul 1, 2018
5a442bf
add missing expandRow props
AllenFang Jul 1, 2018
e6d4a96
data, keyField and columns is necessary value for toolkits context
AllenFang Jul 3, 2018
0ec5b6c
add simple toolkit context wrapper for user
AllenFang Jul 11, 2018
03ece4b
refactoring search
AllenFang Jul 14, 2018
f0e37b1
implement export csv
AllenFang Jul 14, 2018
b792803
add export csv stories
AllenFang Jul 14, 2018
ec77a05
patch docs for export CSV
AllenFang Jul 14, 2018
fadbcda
a workaround for fixing the _ module missing
AllenFang Jul 14, 2018
7919a40
enhance for #402
AllenFang Jul 15, 2018
0d64443
fix sort caret broken on bootstrap4
AllenFang Jul 20, 2018
f7ba8e3
upgrade enzyme
AllenFang Jul 22, 2018
c0416fc
fix selection column broken when bootstrap4
AllenFang Jul 22, 2018
4958757
refine new context API tests
AllenFang Jul 22, 2018
3f957db
fix pagination broken when bootstrap4
AllenFang Jul 22, 2018
62c6949
add bootstrap4 style links
AllenFang Jul 22, 2018
925d3d7
final docs patch
AllenFang Jul 24, 2018
f7406bc
add toolkits styles
AllenFang Jul 28, 2018
2ec55f6
patch for default sort and filter have potential issue when remote
AllenFang Jul 28, 2018
d5d8c54
fix React doesn't allow Date Object as children
AllenFang Jul 28, 2018
cb970cd
fix peerdep
AllenFang Aug 4, 2018
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
patch for remote cell edit
  • Loading branch information
AllenFang committed Aug 1, 2018
commit 0d4d32c6e45d92d60643c6c5f7e1416ae3600a8e
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import React from 'react';
import PropTypes from 'prop-types';
import BootstrapTable from 'react-bootstrap-table-next';
import paginationFactory from 'react-bootstrap-table2-paginator';
import cellEditFactory from 'react-bootstrap-table2-editor';
import filterFactory, { textFilter, Comparator } from 'react-bootstrap-table2-filter';
import Code from 'components/common/code-block';
import { productsGenerator } from 'utils/common';

const products = productsGenerator(87);
let products = productsGenerator(87);

const columns = [{
dataField: 'id',
Expand All @@ -31,6 +32,7 @@ const columns = [{
const sourceCode = `\
import BootstrapTable from 'react-bootstrap-table-next';
import paginationFactory from 'react-bootstrap-table2-paginator';
import cellEditFactory from 'react-bootstrap-table2-editor';
import filterFactory, { textFilter, Comparator } from 'react-bootstrap-table2-filter';
// ...

Expand All @@ -57,16 +59,21 @@ const defaultSorted = [{
order: 'desc'
}];

const cellEditProps = {
mode: 'click'
};

const RemoteAll = ({ data, page, sizePerPage, onTableChange, totalSize }) => (
<div>
<BootstrapTable
remote={ { pagination: true } }
remote
keyField="id"
data={ data }
columns={ columns }
defaultSorted={ defaultSorted }
filter={ filterFactory() }
pagination={ paginationFactory({ page, sizePerPage, totalSize }) }
cellEdit={ cellEditFactory(cellEditProps) }
onTableChange={ onTableChange }
/>
<Code>{ sourceCode }</Code>
Expand All @@ -93,11 +100,25 @@ class Container extends React.Component {
this.handleTableChange = this.handleTableChange.bind(this);
}

handleTableChange = (type, { page, sizePerPage, filters, sortField, sortOrder }) => {
handleTableChange = (type, { page, sizePerPage, filters, sortField, sortOrder, cellEdit }) => {
const currentIndex = (page - 1) * sizePerPage;
setTimeout(() => {
// Handle cell editing
if (type === 'cellEdit') {
const { rowId, dataField, newValue } = cellEdit;
products = products.map((row) => {
if (row.id === rowId) {
const newRow = { ...row };
newRow[dataField] = newValue;
return newRow;
}
return row;
});
}
let result = products;

// Handle column filters
let result = products.filter((row) => {
result = result.filter((row) => {
let valid = true;
for (const dataField in filters) {
const { filterVal, filterType, comparator } = filters[dataField];
Expand Down Expand Up @@ -162,19 +183,24 @@ const defaultSorted = [{
order: 'desc'
}];

const cellEditProps = {
mode: 'click'
};

const RemoteAll = ({ data, page, sizePerPage, onTableChange, totalSize }) => (
<div>
<h3>When <code>remote.pagination</code> is enabled, the filtering,
sorting and searching will also change to remote mode automatically</h3>
<BootstrapTable
remote={ { pagination: true } }
remote
keyField="id"
data={ data }
columns={ columns }
defaultSorted={ defaultSorted }
filter={ filterFactory() }
pagination={ paginationFactory({ page, sizePerPage, totalSize }) }
onTableChange={ onTableChange }
cellEdit={ cellEditFactory(cellEditProps) }
/>
<Code>{ sourceCode }</Code>
</div>
Expand All @@ -200,11 +226,24 @@ class Container extends React.Component {
this.handleTableChange = this.handleTableChange.bind(this);
}

handleTableChange = (type, { page, sizePerPage, filters, sortField, sortOrder }) => {
handleTableChange = (type, { page, sizePerPage, filters, sortField, sortOrder, cellEdit }) => {
const currentIndex = (page - 1) * sizePerPage;
setTimeout(() => {
// Handle cell editing
if (type === 'cellEdit') {
const { rowId, dataField, newValue } = cellEdit;
products = products.map((row) => {
if (row.id === rowId) {
const newRow = { ...row };
newRow[dataField] = newValue;
return newRow;
}
return row;
});
}
let result = products;
// Handle column filters
let result = products.filter((row) => {
result = result.filter((row) => {
let valid = true;
for (const dataField in filters) {
const { filterVal, filterType, comparator } = filters[dataField];
Expand Down