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

Read is never called, even after Save Changes

0 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Samuel
Top achievements
Rank 2
Samuel asked on 18 Nov 2012, 08:55 PM
I've been trying to figure out why my Grid gets out of date and noticed that even after a Save Changes, the grid doesn't call my Read action. If I click on Cancel Changes after I save the changes then all is well (but it still never calls the Read) so I'm at a loss as to why the results end up showing 'undetermined' if I don't click on Cancel Changes and if there's a way to force the page to do whatever it is that Cancel Changes is doing after a Save.

Any ideas? My grid (which uses editor templates and a client template) is:
@model IEnumerable<Datamart.Models.ViewModels.LEAFundMap>
 
@{
    ViewBag.Title = "CreateFundMap";
    var snapshot = Session["snapshot_id"] ?? Request.Params["snapshot_id"];
}
 
<h2>CreateFundMap</h2>
@(Html.Kendo().Grid(Model)
.Name("Funds")
.Columns(cols =>
    {
        cols.Bound(p => p.entity_fund).ClientTemplate("#=entity_fund#");
        cols.Bound(p => p.fund_desc).ClientTemplate("#=fund_desc.fund_desc#");
    })
.ToolBar(commands =>
    {
        commands.Save();
    })   
.Editable(edit => edit.Enabled(true).Mode(GridEditMode.InCell))
.DataSource(ds => ds
            .Ajax()
            .Model(model =>
                {
                    model.Id(p => p.entity_fund);
                    model.Field(p => p.entity_fund).Editable(false);
                     
                })
            // Configure RU -->
                .Read(read => read.Action("Fund_Read", "Draft").Data("additionalData"))
                .Update(update => update.Action("Fund_Update", "Draft").Data("additionalData"))
                //.ServerOperation(false)
                    .Batch(true)
                .Events(events => events
                    //.Change("onChange") // commented out because it causes an infinite loop
                    .Error("onError")                   
                    )
                )
            // <-- Configure RU
             
            )
 
<script>
function additionalData() {
    return {
        snapshot_id: "@snapshot"
    };
}
 
function onError(e, status) {
    if (e.errors) {
        var message = "The following errors have occurred:\n";
 
        $.each(e.errors, function (key, value) {
            if (value.errors) {
                message += value.errors.join("\n");
            }
        });
 
        alert(message);
    }
}
 
function onChange() {
    var grid = $("#Funds").data("kendoGrid");
 
    grid.dataSource.read();
}
</script>

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Samuel
Top achievements
Rank 2
Share this question
or