react-bootstrap-table-ng-editor 4.19.1 → 4.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -38
- package/dist/react-bootstrap-table-ng-editor.js +2 -2
- package/dist/react-bootstrap-table-ng-editor.min.js +2 -2
- package/lib/index.d.ts +1 -16
- package/lib/src/checkbox-editor.d.ts +7 -0
- package/lib/src/checkbox-editor.js +13 -18
- package/lib/src/checkbox-editor.js.map +1 -1
- package/lib/src/context.d.ts +1 -16
- package/lib/src/context.js +4 -21
- package/lib/src/context.js.map +1 -1
- package/lib/src/date-editor.d.ts +5 -0
- package/lib/src/date-editor.js +19 -20
- package/lib/src/date-editor.js.map +1 -1
- package/lib/src/dropdown-editor.d.ts +8 -0
- package/lib/src/dropdown-editor.js +14 -30
- package/lib/src/dropdown-editor.js.map +1 -1
- package/lib/src/editing-cell.d.ts +1 -13
- package/lib/src/editing-cell.js +9 -19
- package/lib/src/editing-cell.js.map +1 -1
- package/lib/src/editor-indicator.d.ts +6 -4
- package/lib/src/editor-indicator.js +2 -7
- package/lib/src/editor-indicator.js.map +1 -1
- package/lib/src/text-editor.d.ts +6 -0
- package/lib/src/text-editor.js +20 -25
- package/lib/src/text-editor.js.map +1 -1
- package/lib/src/textarea-editor.d.ts +7 -0
- package/lib/src/textarea-editor.js +13 -18
- package/lib/src/textarea-editor.js.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
`react-bootstrap-table-ng` separate the cell edit code base to [`react-bootstrap-table-ng-editor`](https://github.com/jeff-k-zhou/react-bootstrap-table-ng/tree/main/packages/react-bootstrap-table-ng-editor), so there's a little bit different when you use cell edit than `react-bootstrap-table`. In the following, we are going to show you how to enable the cell edit
|
|
4
4
|
|
|
5
|
-
**[Live Demo For Cell Edit](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/storybook/
|
|
5
|
+
**[Live Demo For Cell Edit](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/storybook/?path=/docs/cell-editing--docs)**
|
|
6
6
|
|
|
7
7
|
**[API&Props Definitation](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/cell-edit-props.html)**
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
---
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -16,61 +16,66 @@ $ npm install react-bootstrap-table-ng-editor --save
|
|
|
16
16
|
|
|
17
17
|
## How
|
|
18
18
|
|
|
19
|
-
We have [two ways](https://
|
|
19
|
+
We have [two ways](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/cell-edit-props.html#celleditmode-string) to trigger a editable cell as editing cell:
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
- click
|
|
22
|
+
- dbclick
|
|
23
23
|
|
|
24
24
|
That's look into how we enable the cell edit on tabe:
|
|
25
25
|
|
|
26
26
|
```js
|
|
27
|
-
import cellEditFactory from
|
|
27
|
+
import cellEditFactory from "react-bootstrap-table-ng-editor";
|
|
28
28
|
|
|
29
29
|
// omit
|
|
30
30
|
|
|
31
31
|
<BootstrapTable
|
|
32
32
|
keyField="id"
|
|
33
|
-
data={
|
|
34
|
-
columns={
|
|
35
|
-
cellEdit={
|
|
36
|
-
|
|
33
|
+
data={products}
|
|
34
|
+
columns={columns}
|
|
35
|
+
cellEdit={cellEditFactory({ mode: "click" })}
|
|
36
|
+
/>;
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
How user save their new editings? We offer two ways:
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
- Press ENTER(**default**)
|
|
42
|
+
- Blur from current editing cell(Need to enable the [cellEdit.blurToSave](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/cell-edit-props.html#celleditblurtosave-bool))
|
|
43
43
|
|
|
44
44
|
## Editable Cell
|
|
45
|
+
|
|
45
46
|
`react-bootstrap-table-ng` support you to configure the cell editable on three level:
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
- Row Level ([cellEdit.nonEditableRows](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/cell-edit-props.html#celleditnoneditablerows-function))
|
|
49
|
+
- Column Level (Configure [column.editable](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/column-props.html#columneditable-bool-function) as bool value)
|
|
50
|
+
- Cell Level (Configure [column.editable](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/column-props.html#columneditable-bool-function) as a callback function)
|
|
50
51
|
|
|
51
52
|
## Validation
|
|
52
53
|
|
|
53
|
-
[column.validator](https://
|
|
54
|
+
[column.validator](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/column-props.html#columnvalidator-function) will help you to work on it!
|
|
55
|
+
|
|
54
56
|
## Customize Style/Class
|
|
57
|
+
|
|
55
58
|
### Editing Cell
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
- Customize the editing cell style via [column.editCellStyle](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/column-props.html#columneditcellstyle-object-function)
|
|
61
|
+
- Customize the editing cell classname via [column.editCellClasses](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/column-props.html#columneditcellclasses-string-function)
|
|
59
62
|
|
|
60
63
|
### Editor
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
|
|
65
|
+
- Customize the editor style via [column.editorStyle](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/column-props.html#columneditorstyle-object-function)
|
|
66
|
+
- Customize the editor classname via [column.editoClasses](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/column-props.html#columneditorclasses-string-function)
|
|
63
67
|
|
|
64
68
|
## Rich Editors
|
|
69
|
+
|
|
65
70
|
`react-bootstrap-table-ng` have following predefined editor:
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
- Text(Default)
|
|
73
|
+
- Dropdown
|
|
74
|
+
- Date
|
|
75
|
+
- Textarea
|
|
76
|
+
- Checkbox
|
|
72
77
|
|
|
73
|
-
In a nutshell, you just only give a [column.editor](https://
|
|
78
|
+
In a nutshell, you just only give a [column.editor](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/column-props.html#columneditor-object) and define the `type`:
|
|
74
79
|
|
|
75
80
|
```js
|
|
76
81
|
import { Type } from 'react-bootstrap-table-ng-editor';
|
|
@@ -89,9 +94,11 @@ const columns = [
|
|
|
89
94
|
In the following, we go though all the predefined editors:
|
|
90
95
|
|
|
91
96
|
### Dropdown Editor
|
|
97
|
+
|
|
92
98
|
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
99
|
|
|
94
100
|
#### editor.options
|
|
101
|
+
|
|
95
102
|
This is most simple case for assign the dropdown options data directly.
|
|
96
103
|
|
|
97
104
|
```js
|
|
@@ -123,13 +130,13 @@ const columns = [
|
|
|
123
130
|
```
|
|
124
131
|
|
|
125
132
|
#### editor.getOptions
|
|
133
|
+
|
|
126
134
|
It is much flexible which accept a function and you can assign the dropdown options dynamically.
|
|
127
135
|
|
|
128
136
|
There are two case for `getOptions`:
|
|
129
137
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
138
|
+
- _Synchronous_: Just return the options array in `getOptions` callback function
|
|
139
|
+
- _Asynchronous_: Call `setOptions` function argument when you get the options from remote.
|
|
133
140
|
|
|
134
141
|
```js
|
|
135
142
|
// Synchronous
|
|
@@ -160,9 +167,10 @@ const columns = [
|
|
|
160
167
|
|
|
161
168
|
```
|
|
162
169
|
|
|
163
|
-
[here](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/storybook/
|
|
170
|
+
[here](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/storybook/?path=/story/cell-editing--dropdown-editor) is an online example.
|
|
164
171
|
|
|
165
172
|
### Date Editor
|
|
173
|
+
|
|
166
174
|
Date editor is use `<input type="date">`, the configuration is very simple:
|
|
167
175
|
|
|
168
176
|
```js
|
|
@@ -184,6 +192,7 @@ const columns = [
|
|
|
184
192
|
```
|
|
185
193
|
|
|
186
194
|
### Textarea Editor
|
|
195
|
+
|
|
187
196
|
Textarea editor is use `<input type="textarea">`, user can press `ENTER` to change line and in the `react-bootstrap-table-ng`, user allow to save result via press `SHIFT` + `ENTER`.
|
|
188
197
|
|
|
189
198
|
```js
|
|
@@ -196,7 +205,9 @@ const columns = [
|
|
|
196
205
|
}
|
|
197
206
|
}];
|
|
198
207
|
```
|
|
208
|
+
|
|
199
209
|
### Checkbox Editor
|
|
210
|
+
|
|
200
211
|
Checkbox editor allow you to have a pair value choice, the `editor.value` is required value to represent the actual value for check and uncheck.
|
|
201
212
|
|
|
202
213
|
```js
|
|
@@ -212,14 +223,15 @@ const columns = [
|
|
|
212
223
|
```
|
|
213
224
|
|
|
214
225
|
## Customize Editor
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
226
|
+
|
|
227
|
+
If you feel above predefined editors are not satisfied to your requirement, you can certainly custom the editor via [column.editorRenderer](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/column-props.html#columneditorrenderer-function). It accept a function and pass following arguments when function called:
|
|
228
|
+
|
|
229
|
+
- `editorProps`: Some useful attributes you can use on DOM editor, like class, style etc.
|
|
230
|
+
- `value`: Current cell value
|
|
231
|
+
- `row`: Current row data
|
|
232
|
+
- `column`: Current column definition
|
|
233
|
+
- `rowIndex`: Current row index
|
|
234
|
+
- `columnIndex`: Current column index
|
|
223
235
|
|
|
224
236
|
> Note when implement a custom React editor component, this component should have a **getValue** function which return current value on editor
|
|
225
237
|
|