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

About Grid refresh after update

3 Answers 411 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 25 Dec 2012, 04:54 PM

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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 26 Dec 2012, 09:37 AM
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!
0
Gary
Top achievements
Rank 1
answered on 27 Dec 2012, 01:31 PM
Thanks!
0
Kevin
Top achievements
Rank 1
answered on 12 Jul 2017, 09:29 PM
Old post, but this worked like a champ! Thanks!
Tags
Grid
Asked by
Gary
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Gary
Top achievements
Rank 1
Kevin
Top achievements
Rank 1
Share this question
or