mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-08-13 12:20:16 +00:00
patch docs for expand row
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
* [headerClasses](#headerClasses)
|
||||
* [cellEdit](#cellEdit)
|
||||
* [selectRow](#selectRow)
|
||||
* [expandRow](#expandRow)
|
||||
* [rowStyle](#rowStyle)
|
||||
* [rowClasses](#rowClasses)
|
||||
* [rowEvents](#rowEvents)
|
||||
@@ -123,6 +124,9 @@ Makes table cells editable, please see [cellEdit definition](./cell-edit.md) for
|
||||
### <a name='selectRow'>selectRow - [Object]</a>
|
||||
Makes table rows selectable, please see [selectRow definition](./row-selection.md) for more detail.
|
||||
|
||||
### <a name='expandRow'>expandRow - [Object]</a>
|
||||
Makes table rows expandable, please see [expandRow definition](./row-expand.md) for more detail.
|
||||
|
||||
### <a name='rowStyle'>rowStyle = [Object | Function]</a>
|
||||
Custom the style of table rows:
|
||||
|
||||
|
||||
+10
-4
@@ -114,7 +114,7 @@ Remember to install [`react-bootstrap-table2-paginator`](https://www.npmjs.com/p
|
||||
No big changes for pagination, but still can't custom the pagination list, button and sizePerPage dropdown.
|
||||
|
||||
## Table Search
|
||||
the usage of search functionality is a little bit different from legacy search. The mainly different thing is developer have to render the search input field, we do believe it will be very flexible for all the developers who want to custom the search position or search field itself.
|
||||
The usage of search functionality is a little bit different from legacy search. The mainly different thing is developer have to render the search input field, we do believe it will be very flexible for all the developers who want to custom the search position or search field itself.
|
||||
|
||||
- [x] Custom search component and position
|
||||
- [x] Custom search value
|
||||
@@ -122,6 +122,15 @@ the usage of search functionality is a little bit different from legacy search.
|
||||
- [ ] Multiple search
|
||||
- [ ] Strict search
|
||||
|
||||
## Row Expand
|
||||
- [x] Expand Row Events
|
||||
- [x] Expand Row Indicator
|
||||
- [x] Expand Row Management
|
||||
- [x] Custom Expand Row Indicators
|
||||
- [ ] Compatiable with Row Selection
|
||||
- [ ] Expand Column position
|
||||
- [ ] Expand Column Style/Class
|
||||
|
||||
## Remote
|
||||
|
||||
> It's totally different in `react-bootstrap-table2`. Please [see](https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/basic-remote.html).
|
||||
@@ -130,9 +139,6 @@ the usage of search functionality is a little bit different from legacy search.
|
||||
## Row insert/Delete
|
||||
Not support yet
|
||||
|
||||
## Expand row
|
||||
Not support yet
|
||||
|
||||
## Keyboard Navigation
|
||||
Not support yet
|
||||
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
|
||||
# Row expand
|
||||
`react-bootstrap-table2` supports the row expand feature. By passing prop `expandRow` to enable this functionality.
|
||||
|
||||
> Default is click to expand/collapse a row. In addition, we don't support any way to chagne this mechanism!
|
||||
|
||||
## Required
|
||||
* [renderer (**required**)](#renderer)
|
||||
|
||||
## Optional
|
||||
* [expanded](#expanded)
|
||||
* [nonExpandable](#nonExpandable)
|
||||
* [onExpand](#onExpand)
|
||||
* [onExpandAll](#onExpandAll)
|
||||
* [showExpandColumn](#showExpandColumn)
|
||||
* [expandColumnRenderer](#expandColumnRenderer)
|
||||
* [expandHeaderColumnRenderer](#expandHeaderColumnRenderer)
|
||||
|
||||
### <a name="renderer">expandRow.renderer - [Function]</a>
|
||||
|
||||
Specify the content of expand row, `react-bootstrap-table2` will pass a row object as argument and expect return a react element.
|
||||
|
||||
#### values
|
||||
* **row**
|
||||
|
||||
#### examples
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: row => (
|
||||
<div>
|
||||
<p>{ `This Expand row is belong to rowKey ${row.id}` }</p>
|
||||
<p>You can render anything here, also you can add additional data on every row object</p>
|
||||
<p>expandRow.renderer callback will pass the origin row object to you</p>
|
||||
</div>
|
||||
)
|
||||
};
|
||||
|
||||
<BootstrapTable
|
||||
keyField='id'
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
expandRow={ expandRow }
|
||||
/>
|
||||
```
|
||||
|
||||
### <a name='expanded'>expandRow.expanded - [Array]</a>
|
||||
`expandRow.expanded` allow you have default row expandations on table.
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: (row) => ...
|
||||
expanded: [1, 3] // should be a row keys array
|
||||
};
|
||||
```
|
||||
|
||||
### <a name='nonExpandable'>expandRow.nonExpandable - [Array]</a>
|
||||
This prop allow you to restrict some rows which can not be expanded by user. `expandRow.nonExpandable` accept an rowkeys array.
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: (row) => ...
|
||||
nonExpandable: [1, 3 ,5]
|
||||
};
|
||||
```
|
||||
|
||||
### <a name='onExpand'>expandRow.onExpand - [Function]</a>
|
||||
This callback function will be called when a row is expand/collapse and pass following four arguments:
|
||||
`row`, `isExpand`, `rowIndex` and `e`.
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: (row) => ...
|
||||
onExpand: (row, isExpand, rowIndex, e) => {
|
||||
// ...
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### <a name='onExpandAll'>expandRow.onExpandAll - [Function]</a>
|
||||
This callback function will be called when expand/collapse all. It only work when you configure [`expandRow.showExpandColumn`](#showExpandColumn) as `true`.
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: (row) => ...
|
||||
onExpandAll: (isExpandAll, results, e) => {
|
||||
// ...
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### <a name='expandColumnRenderer'>expandRow.expandColumnRenderer - [Function]</a>
|
||||
Provide a callback function which allow you to custom the expand indicator. This callback only have one argument which is an object and contain one property `expanded` which indicate if current row is expanded
|
||||
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: (row) => ...
|
||||
expandColumnRenderer: ({ expanded }) => (
|
||||
// ....
|
||||
)
|
||||
};
|
||||
```
|
||||
|
||||
> By default, `react-bootstrap-table2` will help you to handle the click event, it's not necessary to handle again by developer.
|
||||
|
||||
### <a name='expandHeaderColumnRenderer'>expandRow.expandHeaderColumnRenderer - [Function]</a>
|
||||
Provide a callback function which allow you to custom the expand indicator in the expand header column. This callback only have one argument which is an object and contain one property `isAnyExpands` which indicate if there's any rows are expanded:
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: (row) => ...
|
||||
expandHeaderColumnRenderer: ({ isAnyExpands }) => (
|
||||
// ....
|
||||
)
|
||||
};
|
||||
```
|
||||
|
||||
> By default, `react-bootstrap-table2` will help you to handle the click event, it's not necessary to handle again by developer.
|
||||
|
||||
### <a name='showExpandColumn'>expandRow.showExpandColumn - [Bool]</a>
|
||||
Default is `false`, if you want to have a expand indicator, give this prop as `true`
|
||||
|
||||
```js
|
||||
const expandRow = {
|
||||
renderer: (row) => ...
|
||||
showExpandColumn: true
|
||||
};
|
||||
```
|
||||
Reference in New Issue
Block a user