This is a migrated thread and some comments may be shown as answers.

Canceling an inline edit upon server error

2 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 12 Mar 2019, 06:38 PM
    I can't be the first one to try this.  I am using a Grid with inline editing.  I use a save handler:

(save)="saveHandler($event)"

The saveHandler transmits the change to the server, but then the server throws an exception.  How do I "undo" those changes locally since the grid has already saved by the time the saveHandler is ran (i.e. the Save/Cancel buttons are no longer even visible)?

2 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 12 Mar 2019, 06:53 PM
I should add that I'm using the kendoGridTemplateEditing directive.
0
Dimiter Topalov
Telerik team
answered on 14 Mar 2019, 10:40 AM
Hello John,

The built-in editing directives are applicable to local data only, and modify the data passed to the Grid. To use a remote data service, you can either create a custom editing service, as described in the following section of our documentation:

https://www.telerik.com/kendo-angular-ui/components/grid/editing/editing-directives/#toc-custom-service

... or the regular editing mechanics, outlined in the following section of our documentation (when template forms are used):

https://www.telerik.com/kendo-angular-ui/components/grid/editing/editing-template-forms/

Note that when editing is initiated, the data item is cloned so that it can be later reverted to the original state (for example the Edit service reset item method, but specific implementation may vary).

It is probably also worth mentioning that using Reactive forms as opposed to Template ones is recommended in general, as it provides more fine-grained control over the whole process, as well as the fact that the form group value and the original data item are separate different objects that allow much easier reverting when needed - the original Grid data item is not mutated at all, but instead the FormGroup value is used for all editing-related purposes.

Examples of reactive forms editing in the context of the Grid are available in the following documentation section:

https://www.telerik.com/kendo-angular-ui/components/grid/editing/editing-reactive-forms/

https://www.telerik.com/kendo-angular-ui/components/grid/editing/custom-reactive-editing/

I hope this helps.

Regards,
Dimiter Topalov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Dimiter Topalov
Telerik team
Share this question
or