grid save event

4 posts, 0 answers
  1. DHHS
    DHHS avatar
    59 posts
    Member since:
    Mar 2015

    Posted 26 Aug 2015 Link to this post

    Hi,

     

    I have to get the values user entered on edit in the inline grid. So I have kept save event on gird and trying to access the values on the method but I am not sure how to the get the values.

       @(Html.Kendo().Grid<BHEBS.Areas.Admin.Models.ContractBudgetModel.contractBudgetBUModel>()
            .Name("ContractBudgetBUGrid")
                     .Events(e => e.Save("onSave"))
            .Columns(columns =>
            {
                columns.Bound(p => p.Id);
                columns.Bound(p => p.BusinessUnit);
                columns.Bound(p => p.Description);       
                columns.Bound(p => p.ServiceType);
                columns.Bound(p => p.BUAuthAmt);
                columns.ForeignKey(p => p.SpendPriority, (System.Collections.IEnumerable)ViewData["SpendPriority"], "Value", "Text").Width(120);
                columns.Bound(p => p.ContractBUAmt);
                columns.Bound(p => p.BUBudgetAmt);
                columns.ForeignKey(p => p.contractSpendPriority, (System.Collections.IEnumerable)ViewData["SpendPriority"], "Value", "Text").Width(120);
                columns.Command(command =>
                {
                    command.Edit().HtmlAttributes(new { @class = "btn-primary" });               
                });         
            })       
            .Pageable(pageable => pageable.Refresh(true).PageSizes(true).ButtonCount(5))      
            .Sortable()
            .Scrollable()
            .Filterable()
            .Selectable()
            .Resizable(resize => resize.Columns(true))
            .HtmlAttributes(new { style = "height:450px;" })
            .DataSource(dataSource => dataSource.Ajax().PageSize(10).Read(read => read.Action("ContractBudgetBU_Read", "ContractBudget").Data("additionalInfo"))
                                    .Model(model => { model.Id(p => p.Id); model.Field(p => p.Id).Editable(false); model.Field(p => p.BusinessUnit).Editable(false); model.Field(p => p.Description).Editable(false); model.Field(p => p.ServiceType).Editable(false); model.Field(p => p.BUAuthAmt).Editable(false); model.Field(p => p.BUBudgetAmt).Editable(false); model.Field(p => p.SpendPriority).Editable(false); model.Field(p => p.contractSpendPriority).DefaultValue("Normal"); })
                            .Update(update => update.Action("Update_ContractBudgetBU", "ContractBudget"))))
     
     
     function onSave(e) {
            var data = e.values;
    //I am getting error e.values is undefined.
    }

     

     

    Thanks,

    Veena

  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2566 posts

    Posted 28 Aug 2015 Link to this post

    Hello Veena,

     

    The e.model property is what you need, as explained here:

     

    http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-save

     

    Regards,
    Kiril Nikolov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Veena
    Veena avatar
    14 posts
    Member since:
    Oct 2015

    Posted 18 Jan Link to this post

    Hi, 

    I got the save event work. But I have a requirement where I should show a pop up message with yes or no on grid edit event and wait for the user to respond and then based on the response I should save the event or cancel the event. Message box is showing up but before i respond to the message box, the update event is triggering and going to controller method. Is there a way that i can wait till the user responds and based on the response i should save the event or cancel the event.

     

    Thanks,

    Veena

  5. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 20 Jan Link to this post

    Hello Veena,

     

    A possible solution is simply to prevent the save event by calling e.preventDefault(); and show the box to the user. If user wants to send the changes to the server then you can call explicitly the sync method of the Kendo UI DataSource. This will sync the changes made on the client-side with the server. 

     

     

     

    Regards,
    Boyan Dimitrov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready