Skip to content

Commit 2b410fb

Browse files
Merge branch 'master' of github.com:react-bootstrap-table/react-bootstrap-table2
2 parents e31b5eb + 110744f commit 2b410fb

File tree

70 files changed

+1413
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1413
-154
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: AllenFang
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is. In addition, please search issues before you open a report to make sure there's no any duplicated report
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Screenshots**
21+
If applicable, add screenshots to help explain your problem.
22+
23+
**codesandbox**
24+
Please give a simple and minimal example on https://codesandbox.io so that we can reproduce it easily and handle it effectively
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: AllenFang
7+
8+
---
9+
10+
**Is this feature requested before?**
11+
Please search issues to make sure to create feature which is never report yet.
12+
13+
**Is your feature request related to a problem? Please describe.**
14+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
15+
16+
**Describe the solution you'd like**
17+
A clear and concise description of what you want to happen.
18+
19+
**Describe alternatives you've considered**
20+
A clear and concise description of any alternative solutions or features you've considered.
21+
22+
**Additional context**
23+
Add any other context or screenshots about the feature request here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: I have a question
3+
about: I have a question
4+
title: ''
5+
labels: ''
6+
assignees: AllenFang
7+
8+
---
9+
10+
**Question**
11+
A clear and concise description of you question. In addition, please search issues before you open a question to make sure there's no any duplicated questions.
12+
13+
**Screenshots**
14+
If applicable, add screenshots to help explain your problem.
15+
16+
**codesandbox**
17+
Please give a simple and minimal example on https://codesandbox.io so that we can reproduce it easily.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# react-bootstrap-table2
22

33
[![Build Status](https://travis-ci.org/react-bootstrap-table/react-bootstrap-table2.svg?branch=master)](https://travis-ci.org/react-bootstrap-table/react-bootstrap-table2)
4-
Rebuilt of [react-bootstrap-table](https://github.com/AllenFang/react-bootstrap-table)
4+
Rebuild of [react-bootstrap-table](https://github.com/AllenFang/react-bootstrap-table)
55

66
> Note that `react-bootstrap-table2`'s npm module name is [**`react-bootstrap-table-next`**](https://www.npmjs.com/package/react-bootstrap-table-next) due to the name being already taken.
77

docs/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ import overlayFactory from 'react-bootstrap-table2-overlay';
9898
Actually, `react-bootstrap-table-overlay` is depends on [`react-loading-overlay`](https://github.com/derrickpelletier/react-loading-overlay) and `overlayFactory` just a factory function and you can pass any props which available for `react-loading-overlay`:
9999

100100
```js
101-
overlay={ overlayFactory({ spinner: true, background: 'rgba(192,192,192,0.3)' }) }
101+
overlay={
102+
overlayFactory({
103+
spinner: true,
104+
styles: {
105+
overlay: (base) => ({...base, background: 'rgba(255, 0, 0, 0.5)'})
106+
}
107+
})
108+
}
102109
```
103110

104111
### <a name='caption'>caption - [String | Node]</a>
@@ -334,4 +341,4 @@ handleDataChange = ({ dataSize }) => {
334341
onDataSizeChange={ handleDataChange }
335342
....
336343
/>
337-
```
344+
```

docs/columns.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Available properties in a column object:
1111
* [hidden](#hidden)
1212
* [formatter](#formatter)
1313
* [formatExtraData](#formatExtraData)
14+
* [type](#type)
1415
* [sort](#sort)
1516
* [sortFunc](#sortFunc)
1617
* [sortCaret](#sortCaret)
@@ -132,6 +133,10 @@ The third argument: `components` have following specified properties:
132133
## <a name='formatExtraData'>column.formatExtraData - [Any]</a>
133134
It's only used for [`column.formatter`](#formatter), you can define any value for it and will be passed as fourth argument for [`column.formatter`](#formatter) callback function.
134135

136+
## <a name='type'>column.type - [String]</a>
137+
Specify the data type on column. Available value so far is `string`, `number`, `bool` and `date`. Default is `string`.
138+
`column.type` can be used when you enable the cell editing and want to save your cell data with correct data type.
139+
135140
## <a name='sort'>column.sort - [Bool]</a>
136141
Enable the column sort via a `true` value given.
137142

docs/row-expand.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@
1818
* [expandColumnPosition](#expandColumnPosition)
1919
* [expandColumnRenderer](#expandColumnRenderer)
2020
* [expandHeaderColumnRenderer](#expandHeaderColumnRenderer)
21+
* [parentClassName](#parentClassName)
2122

2223
### <a name="renderer">expandRow.renderer - [Function]</a>
2324

2425
Specify the content of expand row, `react-bootstrap-table2` will pass a row object as argument and expect return a react element.
2526

2627
#### values
2728
* **row**
29+
* **rowIndex**
2830

2931
#### examples
3032

3133
```js
3234
const expandRow = {
33-
renderer: row => (
35+
renderer: (row, rowIndex) => (
3436
<div>
3537
<p>{ `This Expand row is belong to rowKey ${row.id}` }</p>
3638
<p>You can render anything here, also you can add additional data on every row object</p>
@@ -165,3 +167,24 @@ const expandRow = {
165167
expandColumnPosition: 'right'
166168
};
167169
```
170+
171+
### <a name='parentClassName'>expandRow.parentClassName - [String | Function]</a>
172+
Apply the custom class name on parent row of expanded row. For example:
173+
174+
```js
175+
const expandRow = {
176+
renderer: (row) => ...,
177+
parentClassName: 'foo'
178+
};
179+
```
180+
Below case is more flexible way to custom the class name:
181+
182+
```js
183+
const expandRow = {
184+
renderer: (row) => ...,
185+
parentClassName: (isExpanded, row, rowIndex) => {
186+
if (rowIndex > 2) return 'foo';
187+
return 'bar';
188+
}
189+
};
190+
```

docs/row-selection.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
* [clickToEdit](#clickToEdit)
1717
* [onSelect](#onSelect)
1818
* [onSelectAll](#onSelectAll)
19+
* [selectColumnPosition](#selectColumnPosition)
1920
* [hideSelectColumn](#hideSelectColumn)
2021
* [hideSelectAll](#hideSelectAll)
2122
* [selectionRenderer](#selectionRenderer)
2223
* [selectionHeaderRenderer](#selectionHeaderRenderer)
2324
* [headerColumnStyle](#headerColumnStyle)
25+
* [selectColumnStyle](#selectColumnStyle)
2426

2527
### <a name="mode">selectRow.mode - [String]</a>
2628

@@ -224,6 +226,42 @@ const selectRow = {
224226
};
225227
```
226228

229+
### <a name='selectColumnStyle'>selectRow.selectColumnStyle - [Object | Function]</a>
230+
A way to custome the selection cell. `selectColumnStyle` not only accept a simple style object but also a callback function for more flexible customization:
231+
232+
### Style Object
233+
234+
```js
235+
const selectRow = {
236+
mode: 'checkbox',
237+
selectColumnStyle: { backgroundColor: 'blue' }
238+
};
239+
```
240+
241+
### Callback Function
242+
If a callback function present, you can get below information to custom the selection cell:
243+
244+
* `checked`: Whether current row is seleccted or not
245+
* `disabled`: Whether current row is disabled or not
246+
* `rowIndex`: Current row index
247+
* `rowKey`: Current row key
248+
249+
250+
```js
251+
const selectRow = {
252+
mode: 'checkbox',
253+
selectColumnStyle: ({
254+
checked,
255+
disabled,
256+
rowIndex,
257+
rowKey
258+
}) => (
259+
// ....
260+
return { backgroundColor: 'blue' };
261+
)
262+
};
263+
```
264+
227265
### <a name='onSelect'>selectRow.onSelect - [Function]</a>
228266
This callback function will be called when a row is select/unselect and pass following three arguments:
229267
`row`, `isSelect`, `rowIndex` and `e`.
@@ -275,6 +313,16 @@ const selectRow = {
275313
};
276314
```
277315

316+
### <a name='selectColumnPosition'>selectRow.selectColumnPosition - [String]</a>
317+
Default is `left`. You can give this as `right` for rendering selection column in the right side.
318+
319+
```js
320+
const selectRow = {
321+
mode: 'checkbox',
322+
selectColumnPosition: 'right'
323+
};
324+
```
325+
278326
### <a name='hideSelectColumn'>selectRow.hideSelectColumn - [Bool]</a>
279327
Default is `false`, if you don't want to have a selection column, give this prop as `true`
280328

packages/react-bootstrap-table2-editor/README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ const columns = [
8989
In the following, we go though all the predefined editors:
9090

9191
### Dropdown Editor
92-
Dropdown editor give a select menu to choose a data from a list, the `editor.options` is required property for dropdown editor.
92+
Dropdown editor give a select menu to choose a data from a list. When use dropdown editor, either `editor.options` or `editor.getOptions` should be required prop.
93+
94+
#### editor.options
95+
This is most simple case for assign the dropdown options data directly.
9396

9497
```js
9598
import { Type } from 'react-bootstrap-table2-editor';
@@ -119,6 +122,46 @@ const columns = [
119122
}];
120123
```
121124

125+
#### editor.getOptions
126+
It is much flexible which accept a function and you can assign the dropdown options dynamically.
127+
128+
There are two case for `getOptions`:
129+
130+
* *Synchronous*: Just return the options array in `getOptions` callback function
131+
* *Asynchronous*: Call `setOptions` function argument when you get the options from remote.
132+
133+
134+
```js
135+
// Synchronous
136+
137+
const columns = [
138+
..., {
139+
dataField: 'type',
140+
text: 'Job Type',
141+
editor: {
142+
type: Type.SELECT,
143+
getOptions: (setOptions, { row, column }) => [.....]
144+
}
145+
}];
146+
147+
// Asynchronous
148+
149+
const columns = [
150+
..., {
151+
dataField: 'type',
152+
text: 'Job Type',
153+
editor: {
154+
type: Type.SELECT,
155+
getOptions: (setOptions, { row, column }) => {
156+
setTimeout(() => setOptions([...]), 1500);
157+
}
158+
}
159+
}];
160+
161+
```
162+
163+
[here](https://react-bootstrap-table.github.io/react-bootstrap-table2/storybook/index.html?selectedKind=Cell%20Editing&selectedStory=Dropdown%20Editor%20with%20Dynamic%20Options) is an online example.
164+
122165
### Date Editor
123166
Date editor is use `<input type="date">`, the configuration is very simple:
124167

packages/react-bootstrap-table2-editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-bootstrap-table2-editor",
3-
"version": "1.2.3",
3+
"version": "1.3.2",
44
"description": "it's the editor addon for react-bootstrap-table2",
55
"main": "./lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)