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
close icon

Refresh grid after insert using remote save adapter

I have a grid defined like this:
var dataSource = new ej.data.DataManager({
                json: data,
                adaptor: new ej.data.RemoteSaveAdaptor(),
                insertUrl: "/Contrato/AgregarBeneficiario",
                updateUrl: "/Contrato/ActualizarBeneficiario",
                removeUrl: "/Contrato/EliminarBeneficiario"
var grid = new ej.grids.Grid({
                dataSource: dataSource,
                load: function (args) {
                    this.columns[13].commands[0].buttonOption.click = function (args) {
                actionBegin: function (args) {
                    if (args.requestType === "beginEdit" || args.requestType === "add") {
                        this.columns[3].visible = true;
                        this.columns[4].visible = true;
                        this.columns[5].visible = true;
                        this.columns[6].visible = true;
                        this.columns[7].visible = false;
                    else if (args.requestType === "save") {
                        this.columns[3].visible = false;
                        this.columns[4].visible = false;
                        this.columns[5].visible = false;
                        this.columns[6].visible = false;
                        this.columns[7].visible = true;
                        args.data.IdContrato = idContrato;
                toolbar: ["Add", "Edit", "Delete"],
                columns: [
                    { field: "IdBeneficiario", isPrimaryKey: true, isIdentity: true },
                    { field: "IdTiposIdentificacion", headerText: "Tipo id", foreignKeyField: "IdTiposIdentificacion", foreignKeyValue: "Nombre", dataSource: result.listaTiposId },
                    { field: "NumeroId", headerText: "Numero id" },
                    { field: "PrimerNombre", headerText: "Primer nombre", visible: false },
                    { field: "SegundoNombre", headerText: "Segundo nombre", visible: false },
                    { field: "PrimerApellido", headerText: "Primer apellido", visible: false },
                    { field: "SegundoApellido", headerText: "Segundo apellido", visible: false },
                    { field: "NombreCompleto", headerText: "Nombre" },
                    { field: "TelefonoMovil", headerText: "Celular" },
                    { field: "Email", headerText: "Email" },
                    { field: "IdSede", headerText: "Sede", foreignKeyField: "IdSede", foreignKeyValue: "Nombre", dataSource: result.listaSedes },
                    { field: "WelcomeDay", headerText: "Welcome day", editType: "datetimepickeredit", format:"yyyy/MM/dd hh:mm a" },
                    { field: "Observaciones", headerText: "Obs" },
                    { headerText: "Enviar email", width: "160", commands: [{ type: 'Enviar', buttonOption: { cssClass: 'e-flat', iconCss: 'e-update e-icons' } }] },
                    { field: "IdContrato", visible: false }
                editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: "Dialog" },
                locale: "es-CO",
                dataBound: function () {
                    grid.autoFitColumns(['NombreCompleto'], ['TelefonoMovil'], ['Email'], ['WelcomeDay']);

And in the controller, i have the next action which is the insert record action:
public ActionResult AgregarBeneficiario(BeneficiarioViewModel value)
            int idBeneficiario = ContratoServices.SaveBeneficiario(value);
            value.IdBeneficiario = idBeneficiario;
            return Json(new { data = value });

But, after inserting data, grid does not reflect the new record.
I am following the instructions given in documentation at https://ej2.syncfusion.com/javascript/documentation/grid/data-binding/?no-cache=1#remote-save-adaptor
Image attached belongs to the documentation
Thanks for your help,

Juan J.

Attachment: Documentation_a20f9e3c.zip

1 Reply

PS Pavithra Subramaniyam Syncfusion Team March 18, 2019 05:28 AM UTC

Hi Juan,  
Thanks for contacting Syncfusion support. 
We have checked your code example and we suggest your to return the data as given below in the Insert action to overcome the reported behavior.  
public ActionResult Insert(OrdersDetails value) 
            var ord = value; 
            orddata.Insert(0, ord); 
            return Json(value); 
However we will also include this change in our documentation and it will be refreshed in any of our upcoming release. 
Please contact us if you need any further assistance on this.   
Pavithra S. 

Live Chat Icon For mobile
Up arrow icon