We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Refresh Grid after Edit

Hi all, 

It's possible refresh grid after edit command?

This is my code: 

 @{Html.EJ().Grid<Object>("FlatGrid")
                                        .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.data).UpdateURL("/Home/CellEditUpdate").InsertURL("/Home/CellEditInsert").RemoveURL("/Home/CellEditDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
                                        .AllowPaging()
                                        .AllowResizeToFit()
                                        .AllowTextWrap()
                                        .TextWrapSettings(wrap => { wrap.WrapMode(WrapMode.Both); })
                                        .AllowSorting()
                                        .AllowScrolling()
                                        .ScrollSettings(col => { col.Width(1800).Height(460); })
                                        .AllowSelection()
                                        .SelectionType(SelectionType.Single)
                                        .IsResponsive(true)
                                        .EnableResponsiveRow(true)
                                        .AllowFiltering()
                                        .FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
                                        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
                                        .ToolbarSettings(toolbar =>
                                        {
                                            toolbar.ShowToolbar().ToolbarItems(items =>
                                            {
                                                items.AddTool(ToolBarItems.Edit);
                                                items.AddTool(ToolBarItems.Update);
                                              //items.AddTool(ToolBarItems.Delete);
                                          });
                                        })
                                        .Columns(col =>
                                        {
                                            col.Field("Id").HeaderText("Id").IsPrimaryKey(true).Visible(false).Add();
                                            col.Field("Cabin").HeaderText("Cabin").AllowEditing(false).Width(100).Add();
                                            col.Field("Line").HeaderText("Line").AllowEditing(false).AllowResizing().Width(100).Add();
                                            col.Field("Turbine").HeaderText("Turbine").AllowEditing(false).AllowResizing().Width(100).Add();
                                            col.Field("StatusCode").HeaderText("Status code").AllowEditing(false).AllowResizing().Width(150).Add();
                                            col.Field("AlarmDescription").HeaderText("Main fault description").AllowEditing(false).AllowResizing().Width(150).Add();
                                            col.Field("AddnAllarmDescription").HeaderText("Additional fault description").AllowEditing(false).AllowResizing().Width(150).Add();
                                            col.Field("FalckTaxonomy").HeaderText("Allocated taxonomy").AllowEditing(false).AllowResizing().Width(150).Add();
                                            col.Field("Timekey").HeaderText("Timekey").AllowEditing(false).AllowResizing().Width(125).Add();
                                            col.Field("dt_from").HeaderText("Start Date").Format("{0:dd/MM/yyyy HH:mm:ss}").AllowEditing(false).AllowResizing().Width(150).Add();
                                            col.Field("dt_to").HeaderText("End Date").Format("{0:dd/MM/yyyy HH:mm:ss}").AllowEditing(false).AllowResizing().Width(150).Add();
                                            col.Field("KindofActivity").HeaderText("Kind of Activity").EditType(EditingType.Dropdown).DataSource((IEnumerable<object>)ViewBag.kindofactivities).AllowResizing().Width(150).Add();
                                            col.Field("ReasonDescription").HeaderText("Reason Description").AllowResizing().Width(150).Add();
                                            col.Field("MA_StatusCode").HeaderText("Reallocated status code").AllowEditing(true).EditType(EditingType.Dropdown).DataSource((IEnumerable<object>)ViewBag.alarms).ForeignKeyField("MA_StatusCode").AllowResizing().Width(150).Add();
                                          //col.Field("Reallocated_FaultDescription").HeaderText("Reallocated Fault Description").EditType(EditingType.Dropdown).DataSource((List<object>)ViewBag.alarms1).AllowResizing().Width(150).Add();
                                          //col.Field("Reallocated_AddFaultDescription").HeaderText("Reallocated Add Fault Description").EditType(EditingType.Dropdown).DataSource((List<object>)ViewBag.alarms2).AllowResizing().Width(150).Add();
                                          //col.Field("Reallocated_Taxonomy").HeaderText("Reallocated Taxonomy").AllowEditing(false).AllowResizing().Width(150).Add();
                                          col.Field("FullDescription").HeaderText("Reallocated Full Description").EditType(EditingType.Dropdown).DataSource((IEnumerable<object>)ViewBag.FullAlarm).ForeignKeyField("FullDescription").AllowResizing().Width(400).Add();
                                            col.Field("timekey_changed").HeaderText("Timekey Changed").EditType(EditingType.Numeric).ValidationRules(v => v.AddRule("range", "[1,6]").AddRule("required", true)).Width(150).Add();
                                            col.Field("Timekey_ReasonDescription").HeaderText("Timekey Reason Description").AllowResizing().Width(150).Add();
                                            col.Field("Unallocated_alarms_flag").HeaderText("Unallocated_alarms_flag").AllowResizing().Visible(false).Width(150).Add();
                                            col.Field("ServiceCompany").HeaderText("Service Company").EditType(EditingType.Dropdown).DataSource((IEnumerable<object>)ViewBag.service).AllowResizing().Width(150).Add();
                                            col.Field("Responsability").HeaderText("Responsability").AllowResizing().Width(150).Add();
                                            col.Field("sk_plant").HeaderText("sk_plant").AllowResizing().Visible(false).Add();
                                        }).Render();
}


Thanks,
Nicholas

1 Reply

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team January 24, 2017 12:10 PM UTC

Hi Nicholas,  
 
Thanks for contacting Syncfusion Support. 
 
Usually, Grid will refresh its content once after updating any changes to records in the server and update the same to corresponding record. However, we can also manually refresh the Grid content using the refreshContent method of the Grid. This method can be called in the ActionComplete event of the Grid while requestType as “save”. Refer to the following API Reference. 
 
@{Html.EJ().Grid<Object>("FlatGrid") 
                .Datasource(ds => 
                    ds.Json((IEnumerable<object>)ViewBag.data) 
                    .UpdateURL("/Home/CellEditUpdate") 
                    .InsertURL("/Home/CellEditInsert") 
                    .RemoveURL("/Home/CellEditDelete") 
                    .Adaptor(AdaptorType.RemoteSaveAdaptor)) 
                     .. . .  
                 .. . . . 
                .ClientSideEvents(events => events.ActionComplete("Complete")) 
                .Render(); 
} 
 
<script> 
 
    function Complete(args) { 
        if (args.requestType == "save") 
            this.refreshContent(); 
    }; 
 
</script> 


Loader.
Live Chat Icon For mobile
Up arrow icon