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