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

Retrieving changed data in grid edit mode

1 Answer 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kahl
Top achievements
Rank 1
Kahl asked on 15 Nov 2016, 09:23 AM

I have a grid that has a command edit , I would like to retrieve the new text in the events.Save("onEdit")) javascript.

I cannot see how to do this, and cannot locate any samples in the forms.

 

My current function and grid is below.  How can I retrieve the data from the email address when the update button is selected in edit more.

 

function onEdit(e) {
e.preventDefault();
alert("save 1");
var grid = $("#siteManagementNotifications").data("kendoGrid");
var tr = $(e.target).closest("tr");
var data = this.dataItem(tr);
alert(data.emailAddress);

}

 

@(Html.Kendo().Grid<WebSite.Library.Models.SiteNotifications>()
.Name("siteManagementNotifications")
.Columns(columns =>
{
columns.Bound(p => p.siteId).Title("Id").Width(50).Hidden();
columns.Bound(p => p.siteNotificationId).Title("Id").Width(50).Hidden();
columns.Bound(p => p.siteNotification).Title("Type").Width(50);
columns.Bound(p => p.emailAddress).Title("Notification").Width(120).EditorTemplateName("TextBoxEditor");
//columns.Command(command => command.Custom("Save").Click("SaveSiteNotification")).Width(180);
columns.Command(command => { command.Edit(); }).Width(250);
})

.Events(events => events.Save("onEdit"))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.NoRecords("No notifications exist.")
.DataSource(source => source
.Custom()
.Schema(schema => schema
.Model(m => m.Id(p => p.siteNotificationId)))
.Transport(transport => transport
.Read(read =>
{
read.Url("/Api/SiteInfo/_getNotifications/" + Model.SiteId)
.DataType("json");
})
))
)

1 Answer, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 17 Nov 2016, 08:10 AM
Hi Kahl,

You can use the Save event argument for getting the new values from the edited item model:
function onEdit(e) {
    e.preventDefault();
    alert(e.model.ProductName);
}

Hope this helps.


Regards,
Konstantin Dikov
Telerik by Progress
Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Kahl
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or