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

Refresh Kendo MVC Detail Grid After Update

1 Answer 289 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt Miller
Top achievements
Rank 1
Matt Miller asked on 18 Sep 2013, 07:01 PM
I have a ajax bound grid with master / detail. Having problems getting the detail grid to refresh after saving an update. The data is saving correctly, you can see it update after i force the action method of the controller to be called by doing a sort. For that reason, i thought reading the datasource again from a client side event handler for the save event would do the trick. 

Here's my client detail template in the view:

<script id="matchedTrainTemplate" type="text/x-kendo-template">
    
     
    @(Html.Kendo().Grid<CNX.Domain.Entities.MatchedT94EDI417Railcar>()
            .Name("MatchingEDI417s_#=Id#")
            .Editable(editable => editable.Mode(GridEditMode.PopUp).Window(w => w.Modal(true)
                                                                               .Width(500)
                                                                               .Height(510)
                                                                               .Resizable(x => x.Enabled(true))
                                                                               //.Events(x => x.Close("ClosingEditWindow"))
                                                                               )  )
          .Columns(columns =>
            {               
                columns.Bound(o => o.MATCHING_GUID).Visible(false);
                columns.Bound(o => o.N7_GUID).Visible(false);
                columns.Bound(o => o.EDI_OWNER_CODE).Width("50");
                columns.Bound(o => o.T94_OWNER_CODE).Width("50");
                columns.Bound(o => o.EDI_EQUIPMENT_NUMBER).Width("75");
                columns.Bound(o => o.T94_EQUIPMENT_NUMBER).Width("75");
                columns.Bound(o => o.EDI_GROSS_WEIGHT).Width("75");
                columns.Bound(o => o.EDI_TARE_WEIGHT).Width("75");
                columns.Bound(o => o.T94_SEQUENCE_NUMBER);
                columns.Command(commands => { commands.Edit(); }).Title("Edit Railcar").Width("50");            
                columns.Bound(o => o.RREGUID).Visible(false);
                columns.Bound(o => o.EDI_417_GUID).Visible(false);
                columns.Bound(o => o.HeaderGuid).Visible(false);
            })
            .DataSource(dataSource => dataSource.Ajax()
                                                .PageSize(10)
                                                .Model(model => model.Id(o => o.MATCHING_GUID))
                                                .Read(read => read.Action("MatchedEDI417sDetail", "MenuEDI", new { matchingGuid = "#=Id#" }).Type(HttpVerbs.Post))                                               
                                                .Update(update => update.Action("MatchedEDI417sUpdate", "MenuEDI" , Model).Type(HttpVerbs.Post))                                               
            )
            .Pageable()
            .Sortable()
            .Filterable()
            .Events( events => events.Save("detailSave"))
            .ToClientTemplate()
    );
 
    
 
</script>
 
<script>  
 
    function detailSave() {
        alert('Save Event');
        this.dataSource.read();
    }
</script>
Here's the controller action method:

[HttpPost]
        public ActionResult MatchedEDI417sUpdate(MatchedT94EDI417Railcar railCar, [DataSourceRequest] DataSourceRequest request)
        {
            TempData["role"] = GetRole();
            matchedT94EDI417RailCarRepository.Save(railCar);                 
                   return Json(matchedT94EDI417RailCarRepository.RailCarsMatchedT94EDI417(railCar.MATCHING_GUID).ToDataSourceResult(request));                
            
        }

Any suggestions appreciated.

1 Answer, 1 is accepted

Sort by
0
Matt Miller
Top achievements
Rank 1
answered on 18 Sep 2013, 08:23 PM
nvm, i'm an idiot. i was returning the entire repository rather than the individual item being updated.
Tags
Grid
Asked by
Matt Miller
Top achievements
Rank 1
Answers by
Matt Miller
Top achievements
Rank 1
Share this question
or