About Grid refresh after update

4 posts, 1 answers
  1. Gary
    Gary avatar
    5 posts
    Member since:
    Nov 2011

    Posted 25 Dec 2012 Link to this post

    Hi,

    It's a bug?
    In hierarchy grid, and Inline Edit mode.

    When I updated, and the RETURN result is null,
    But why the Grid still has data?

    MVC APSX:

    <%:
            Html.Kendo().Grid<CarryingCapacityMD>()
                .Name("Grid").ToolBar(commands => commands.Create())
                .Columns
                (
                    columns =>
                    {
                        columns.Bound(o => o.Tonnage).Width(75).Format("{0:0.00}");
                        columns.Bound(o => o.CageCount).Width(75);
                        columns.Command
                        (
                            commands =>
                            {
                                commands.Edit();
                                commands.Destroy();
                            }
                        ).Width(180).Title("操作");
                    }
                )
                .ClientDetailTemplateId("freightInformationTemplate")
                .DataSource
                (
                    dataSource =>
                        dataSource.Ajax()
                            .Model
                            (
                                model =>
                                {
                                    model.Id(p => p.CarryingCapacityID);
                                }
                            )
                            .Read("_AjaxCarryingCapacityList", "Configurations")
                            .Update("_AjaxCarryingCapacityUpdate", "Configurations")
                            .Destroy("_AjaxCarryingCapacityDelete", "Configurations")
                            .Create("_AjaxCarryingCapacityInsert", "Configurations")
                )
                .Editable(editing => editing.Mode(GridEditMode.PopUp))
        %>
        <script id="freightInformationTemplate" type="text/kendo-tmpl">
            <%:
                Html.Kendo().Grid<FreightInformation>()
                    .Name("FreightInfo_#=CarryingCapacityID#")
                    .Columns
                    (
                        columns =>
                        {
                            columns.Bound(o => o.LocationName).Width(75);
                            columns.Bound(o => o.Mileage).Width(75);
                            columns.Bound(o => o.Freight).Width(75).Format("{0:¥0.00}");
                            columns.Command(command => { command.Edit(); });
                        }
                    )
                    .DataSource
                    (
                        dataSource => dataSource.Ajax().ServerOperation(true)
                            .Model
                            (
                                model =>
                                {
                                    model.Id(p => p.FreightID);
                                    model.Field(p => p.LocationName).Editable(false);
                                    model.Field(p => p.Mileage).Editable(false);
                                }
                            )
                            .Read("_AjaxGetFreightInfoListByCarryingCapacityID", "Configurations", new { carryingCapacityID = "#=CarryingCapacityID#" })
                            .Update("_AjaxLocationUpdateForCarryingCapacity", "Configurations")
                    )
                    //.Events(events => { events.SaveChanges("onSave");})
                    .Editable(editing => editing.Mode(GridEditMode.InLine))
                    //.ToolBar(commands => { commands.Save(); })
                    .ToClientTemplate()
             %>

    Behind Code:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult _AjaxLocationUpdateForCarryingCapacity(FreightInformation updatedFreightInformation)
    {
        if (ModelState.IsValid)
        {
            freightRepository.UpdateForCarryingCapacity(updatedFreightInformation);
        }
        freightRepository = new FreightRepository();
        return Json(freightRepository.GetFreightInfoByCarryingCapacityID(updatedFreightInformation.CarryingCapacityID)); //this result is null
    }

    But after update,
    the grid is still show data.

    Please see attachment file.

  2. Answer
    Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 26 Dec 2012 Link to this post

    Hello,

    You need to use the ToDataSourceResult method as explained in the documentation. Basically you do not need to return the record - just the ModelState.

    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Gary
    Gary avatar
    5 posts
    Member since:
    Nov 2011

    Posted 27 Dec 2012 Link to this post

    Thanks!
  4. Kevin
    Kevin avatar
    2 posts
    Member since:
    Oct 2015

    Posted 12 Jul 2017 in reply to Petur Subev Link to this post

    Old post, but this worked like a champ! Thanks!
Back to Top