Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 37de936

Browse files
committed
docs: add Row Based Editing documentation
1 parent 6d4640a commit 37de936

File tree

8 files changed

+94
-19
lines changed

8 files changed

+94
-19
lines changed

docs/TOC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
* [Row Detail](grid-functionalities/row-detail.md)
7272
* [Row Selection](grid-functionalities/Row-Selection.md)
7373
* [Tree Data Grid](grid-functionalities/Tree-Data-Grid.md)
74+
* [Row Based Editing Plugin](grid-functionalities/Row-based-edit.md)
7475
* [FAQ](grid-functionalities/FAQ.md)
7576

7677
## Backend Services

docs/column-functionalities/Cell-Menu.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- [UI Sample](#ui-sample)
88

99
### Demo
10-
[Demo](https://ghiscoding.github.io/Angular-Slickgrid/#/context) / [Demo Component](/ghiscoding/angular-slickgrid/blob/master/src/app/examples/grid-contextmenu.component.ts)
10+
[Demo](https://ghiscoding.github.io/Angular-Slickgrid/#/context) / [Demo Component](https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-contextmenu.component.ts)
1111

1212
### Description
1313
A Cell Menu, most often used as an Action Menu and is more oriented on a row action (e.g. delete current row), it could be defined on 1 or more columns (defined in a column definition) and is triggered by a cell click or touch. The menu can show a list of Commands (to execute an action) and/or Options (to change the value of a field). Also note that the Commands list is following the same structure used in the [Context Menu](../grid-functionalities/Context-Menu.md), [Header Menu](../grid-functionalities/Header-Menu-&-Header-Buttons.md) & [Grid Menu](../grid-functionalities/Grid-Menu.md). The Cell Menu is very similar to the [Context Menu](../grid-functionalities/Context-Menu.md), both were create as SlickGrid plugins during the same period, their main difference is that they get triggered differently (cell click vs mouse right+click) and they serve different purposes. The Cell Menu is more oriented on a row action (e.g. delete current row) while the Context Menu is all about actions for the entire grid (e.g. export to Excel).

docs/column-functionalities/Editors.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,4 +571,7 @@ onAfterEditCell($event) {
571571
onBeforeEditCell($event) {
572572
this.angularGrid.resizerService.pauseResizer(true);
573573
}
574-
```
574+
```
575+
576+
## Turning individual rows into edit mode
577+
Using the [Row Based Editing Plugin](../grid-functionalities/Row-based-edit.md) you can let the user toggle either one or multiple rows into edit mode, keep track of cell changes and either discard or save them on an individual basis using a custom `onBeforeRowUpdated` hook.

docs/column-functionalities/filters/Autocomplete-Filter-(Kraaden-lib).md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class GridBasicComponent implements OnInit {
6868
```
6969

7070
### Filter Options (`AutocompleterOption` interface)
71-
All the available options that can be provided as `filterOptions` to your column definitions can be found under this [AutocompleterOption interface](/ghiscoding/angular-slickgrid/blob/master/src/app/modules/angular-slickgrid/models/autocompleterOption.interface.ts) and you should cast your `filterOptions` to that interface to make sure that you use only valid options of the jQueryUI autocomplete library.
71+
All the available options that can be provided as `filterOptions` to your column definitions can be found under this [AutocompleterOption interface](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/interfaces/autocompleterOption.interface.ts) and you should cast your `filterOptions` to that interface to make sure that you use only valid options of the jQueryUI autocomplete library.
7272

7373
```ts
7474
filter: {

docs/grid-functionalities/Grid-State-&-Preset.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
### Demo
99
Look at your developer console before leaving the page
1010
#### Regular grid
11-
[Demo Page](https://ghiscoding.github.io/Angular-Slickgrid/#/clientside) / [Demo Component](/ghiscoding/angular-slickgrid/blob/master/src/app/examples/grid-clientside.component.ts)
11+
[Demo Page](https://ghiscoding.github.io/Angular-Slickgrid/#/clientside) / [Demo Component](https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-clientside.component.ts)
1212

1313
#### with Backend Service
14-
[Demo Page](https://ghiscoding.github.io/Angular-Slickgrid/#/gridgraphql) / [Demo Component](/ghiscoding/angular-slickgrid/blob/master/src/app/examples/grid-graphql.component.ts)
14+
[Demo Page](https://ghiscoding.github.io/Angular-Slickgrid/#/gridgraphql) / [Demo Component](https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-graphql.component.ts)
1515

1616
## Descriptions
1717
#### Grid State
1818
The `Grid State` are what we defined as the currently used `Columns` / `Filters` / `Sorters` / `Pagination` of the actual grid (pagination is only returned when used with Backend Service API). The columns also include their (size, position order & visibility (show/hidden)).
1919
#### Presets
20-
Presets can be used to preset a grid with certain `Columns` / `Filters` / `Sorters` / `Pagination`. When we say `Columns`, we actually mean their size, order position and visibility (shown/hidden) in the grid.
20+
Presets can be used to preset a grid with certain `Columns` / `Filters` / `Sorters` / `Pagination`. When we say `Columns`, we actually mean their size, order position and visibility (shown/hidden) in the grid.
2121
#### Combining the two together
2222
So basically, the idea is to save the `Grid State` in Local Storage (or DB) before the grid gets destroyed and once we come back to that same page we can preset the grid with the exact same state as it was before leaving the page (just like if we were doing a forward/back button with browser history).
2323

@@ -26,10 +26,10 @@ You can get the `Grid State` at any point in time. However if you wish to save t
2626

2727
##### View
2828
```html
29-
<angular-slickgrid
29+
<angular-slickgrid
3030
gridId="grid2"
31-
[columnDefinitions]="columnDefinitions"
32-
[gridOptions]="gridOptions"
31+
[columnDefinitions]="columnDefinitions"
32+
[gridOptions]="gridOptions"
3333
[dataset]="dataset"
3434
(onAngularGridCreated)="angularGridReady($event.detail)"
3535
(onBeforeGridDestroy)="saveCurrentGridState($event)">
@@ -167,13 +167,13 @@ export class ExampleComponent implements OnInit {
167167
}
168168
```
169169

170-
#### 2. Through `onGridStateChanged` Observable on the GridState Service
170+
#### 2. Through `onGridStateChanged` Observable on the GridState Service
171171
##### View
172172
```html
173-
<angular-slickgrid
173+
<angular-slickgrid
174174
gridId="grid2"
175-
[columnDefinitions]="columnDefinitions"
176-
[gridOptions]="gridOptions"
175+
[columnDefinitions]="columnDefinitions"
176+
[gridOptions]="gridOptions"
177177
[dataset]="dataset"
178178
(onAngularGridCreated)="angularGridReady($event.detail)"
179179
(onBeforeGridDestroy)="saveCurrentGridState($event)">
@@ -199,7 +199,7 @@ export class ExampleComponent implements OnInit, OnDestroy {
199199
```
200200

201201
## How to Load Grid with certain Columns Preset (example hide certain Column(s) on load)
202-
You can show/hide or even change column position all via the `presets`, yes `presets` is that powerful. All you need is to pass all Columns that you want to show as part of the `columns` property of `presets`. Typically you already have the entire columns definition since you just defined it, so you can re-use that and just use `map` to loop through and populate the `columns` according to the structure needed (see [preset structure](#structure)). What you have to know is that whatever array you pass will drive what the user will see and at which order the columns will show (basically the array order does matter). If a Columns is omitted from that array, then it will become a hidden column (you can still show it through Grid Menu or Column Picker).
202+
You can show/hide or even change column position all via the `presets`, yes `presets` is that powerful. All you need is to pass all Columns that you want to show as part of the `columns` property of `presets`. Typically you already have the entire columns definition since you just defined it, so you can re-use that and just use `map` to loop through and populate the `columns` according to the structure needed (see [preset structure](#structure)). What you have to know is that whatever array you pass will drive what the user will see and at which order the columns will show (basically the array order does matter). If a Columns is omitted from that array, then it will become a hidden column (you can still show it through Grid Menu or Column Picker).
203203

204204
So let say that we want to hide the last Column on page load, we can just find the column by it's `id` that you want to hide and pass the new column definition to the `presets` (again make sure to follow the correct preset structure).
205205

@@ -213,8 +213,8 @@ this.columnDefinitions = [
213213
// and use `map()` to only pull required field for presets to work
214214
const mappedColumnDefinitions = this.columnDefinitions.map((col) => {
215215
return { columnId: col.id, width: col.width };
216-
});
217-
mappedColumnDefinitions.pop();
216+
});
217+
mappedColumnDefinitions.pop();
218218

219219
// then pass it to the presets
220220
this.gridOptions = {
@@ -223,7 +223,7 @@ this.gridOptions = {
223223
}
224224
};
225225
```
226-
This would be the easiest way to do it.
226+
This would be the easiest way to do it.
227227
228228
As pointed out earlier, the `presets` requires a specific structure where the `columns` is the list of columns to show/hide with their possible widths and also the position in the array is very important as it defines the position shown in the UI
229229
```ts

docs/grid-functionalities/Resize-by-Cell-Content.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- [Resize by Content - Column Options](#resize-by-content---column-options)
55

66
### Demo
7-
[Demo](https://ghiscoding.github.io/Angular-Slickgrid/#/resize-by-content) / [Demo Component](/ghiscoding/angular-slickgrid/blob/master/src/app/examples/grid-resize-by-content.component.ts)
7+
[Demo](https://ghiscoding.github.io/Angular-Slickgrid/#/resize-by-content) / [Demo Component](https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-resize-by-content.component.ts)
88

99
### Description
1010
The default of Slickgrid-Universal is to fit all columns in the container viewport and for the most part that is a good resize to use and it's fast. However if your grid has a lot of columns then doing a fit to viewport is not exactly great, you have lot of columns a few of these columns will become too small (we strongly suggest adding `minWidth` to every column) and you'll start seeing ellipsis to a few of these columns.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#### index
2+
- [The action column](#the-action-column)
3+
- [Multiple Row Selections](#multiple-row-selections)
4+
- [Change Dynamically Single/Multiple Selections](#changing-dynamically-from-single-to-multiple-selections-and-vice-versa)
5+
- [Mixing Single & Multiple Row Selections](#mixing-single--multiple-row-selections)
6+
- [Disable Custom Rows Selections via `selectableOverride`](#disable-custom-rows-selections-via-selectableoverride)
7+
- [Disable External Button when having Empty Selection](#disable-external-button-when-having-empty-selection)
8+
- [Change Row Selections](#change-row-selections)
9+
- Troubleshooting
10+
- [Adding a Column dynamically is removing the Row Selection, why is that?](#adding-a-column-dynamically-is-removing-the-row-selection-why-is-that)
11+
12+
### Description
13+
The Row based editing plugin makes it possible to keep the grid readonly except for rows which the user explicitely toggles into edit mode.
14+
15+
**Note:** This plugin enforces the use of the `autoEdit` option and will turn it on with a console warning if its not already.
16+
17+
### Demo
18+
[Demo](https://ghiscoding.github.io/Angular-Slickgrid/#/base-row-editing) / [Demo Component](https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-base-row-editing.component.ts)
19+
20+
## The action column
21+
A new column is rendered that shows an edit/delete button. If the user clicks on edit, a save and cancel button are shown instead and the row toggles into edit mode. By default as the last column but you can override it with the option `columnIndexPosition`. Additionally it's default column id can be overriden using the opiton `columnId`. Furthermore, you can also override the columns label via the `actionsColumnLabel` property.
22+
23+
### Single or multiple editable rows
24+
By default you can only toggle a single row into edit mode. If you set the option `allowMultipleRows` to `true` on the other hand, you can toggle as many as you want.
25+
26+
### Configuring the action buttons
27+
You can override the styling, the hover text as well as whether a prompt — and with what text — should be shown. It is done by overriding the `actionButtons` property of the [plugins options](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/interfaces/rowBasedEditOption.interface.ts).
28+
29+
## Support for the Excel Copy Buffer Plugin
30+
If the [Excel Copy Buffer Plugin](excel-copy-buffer.md) is configured, the Row based editing pluging will override it's behavior by denying pastes on all cells not within a edit mode row. Nevertheless, any existing `BeforePasteCellHandler` will be respected.
31+
32+
## How the plugin works
33+
The idea of the plugin is to focus the users editing experience on specific individual rows and and save them individually. This is achieved by letting the user toggle one or more rows into edit mode.
34+
When a that happens a potentially registered `onBeforeEditMode` callback is executed to handle various preparation or cleanup tasks. Now changes can be made to those rows and will be highlighted and tracked. The user may cancel the edit mode at any time and revert all cells changes. If the save button is pressed on the other hand an `onBeforeRowUpdated` hook, which you define via plugin options, is called and expects a `Promise<boolean>`. In that method you'd typically write the changes to your backend and return either true or false based on the operations outcome. If a negative boolean is returned the edit mode is kept, otherwise the row applies the changes and toggles back into readonly mode. That means, no modifications can be done on the grid.
35+
36+
Here's the respective code shown in Example22:
37+
38+
#### ViewModel
39+
```ts
40+
onBeforeRowUpdated(args) {
41+
const { effortDriven, percentComplete, finish, start, duration, title } = args.dataContext;
42+
43+
if (duration > 40) {
44+
alert('Sorry, 40 is the maximum allowed duration.');
45+
return Promise.resolve(false);
46+
}
47+
48+
return fakeFetch('your-backend-api/endpoint', {
49+
method: 'POST',
50+
body: JSON.stringify({ effortDriven, percentComplete, finish, start, duration, title }),
51+
headers: {
52+
'Content-type': 'application/json; charset=UTF-8'
53+
}
54+
}).catch(err => {
55+
console.error(err);
56+
return false;
57+
})
58+
.then(response => {
59+
if (response === false) { // <---- the negative response, e.g validation failed, keep the row as is
60+
return false;
61+
}
62+
if (typeof response === 'object') {
63+
return response!.json();
64+
}
65+
})
66+
.then(json => {
67+
alert(json.message);
68+
return true; // <--- all good, apply changes in grid and toggle row into readonly mode
69+
});
70+
},
71+
```

docs/styling/styling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Default compiled `css` (if you use the plain Bootstrap Theme CSS, you could simp
2121
```
2222

2323
#### SASS (`.scss`)
24-
You could also compile the SASS files with your own customization, for that simply take any of the [_variables.scss](/ghiscoding/angular-slickgrid/blob/master/src/app/modules/angular-slickgrid/styles/_variables.scss) (without the `!default` flag) variable file and make sure to import the Bootstrap Theme afterward. For example, you could modify your `style.scss` with the following changes:
24+
You could also compile the SASS files with your own customization, for that simply take any of the [_variables.scss](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/_variables.scss) (without the `!default` flag) variable file and make sure to import the Bootstrap Theme afterward. For example, you could modify your `style.scss` with the following changes:
2525

2626
```scss
2727
/* for example, let's change the mouse hover color */

0 commit comments

Comments
 (0)