Retrieving changed data in grid edit mode

2 posts, 1 answers
  1. Kahl
    Kahl avatar
    15 posts
    Member since:
    Nov 2016

    Posted 15 Nov 2016 Link to this post

    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");
    })
    ))
    )

  2. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 17 Nov 2016 Link to this post

    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.
Back to Top