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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Refresh grid after insert using remote save adapter

Thread ID:

Created:

Updated:

Platform:

Replies:

143376 Mar 18,2019 02:43 AM UTC Mar 18,2019 05:28 AM UTC JavaScript - EJ 2 1
loading
Tags: Grid
Juan José
Asked On March 18, 2019 02:43 AM UTC

Hi,
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']);
                }
            });
            grid.appendTo("#grdBeneficiarios");


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

Pavithra Subramaniyam [Syncfusion]
Replied On 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.  
 
[controller.cs] 
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.   
 
Regards, 
Pavithra S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon