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

Passing original values when updating row in grid?

3 Answers 1226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 18 Oct 2017, 02:26 PM

How can I get the original values of the row when calling an update function?

My main issue is that we have a few tables where the primary key is a value we allow to be changed. However, the default auto-generated update functions will fail on update if that value is changed in the grid editor because it won't be able to lookup the row you're updating since it only knows what you want to change the value to and tries to look the row up by the new value.

How can we handle this situation?

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Oct 2017, 07:34 AM
Hello, Michael,

The original value(before edit) can be retrieved on the beforeEdit event of the Grid and saved in a variable to be used later if the Primary Key was edited:

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-beforeEdit

The variable can be passed to the server using the update.data property of the dataSource:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.update.data

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Brian
Top achievements
Rank 1
answered on 14 Nov 2018, 03:42 PM
Hi Stefan, I am trying to implement this functionality in a grid today, the doc you refer to doesn't mention anything about how to obtain the original value. I assume it has changed since this post was written, but how do we go about getting the value now?
0
Konstantin Dikov
Telerik team
answered on 16 Nov 2018, 09:25 AM
Hello Brian,

The "beforeEdit" event exposes the model in the arguments, which holds the values before the changes that will be applied during the editing:
beforeEdit: function(e) {
    var dataItem = e.model;
  }

Hope this helps.


Regards,
Konstantin Dikov
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
Michael
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Brian
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or