- Home
- Forum
- JavaScript - EJ 2
- Got error building grid
Got error building grid
Hi,
Attachment: Error_b41c1e66.zip
I am trying to build a grid with next code:
$.ajax({
url: "/Contrato/Beneficiarios?idContrato=" + idContrato,
type: "GET",
cache: true,
success: function (result) {
var x = result.listaBeneficiarios;
alert("hola");
var grid = new ej.grids.Grid({
datasource: result.listaBeneficiarios,
toolbar: ["Add", "Edit", "Delete"],
columns: [
{ field: "Id", isPrimaryKey: true, isIdentity: true, visible: false },
{ 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.listaTiposId },
{ field: "WelcomeDay", headerText: "Welcome day", editType: "datetimepickeredit" },
{ field: "Observaciones", headerText: "Obs" }
//{ headerText: "Enviar email", width: "160", commands(comandos) }
],
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: "Dialog" },
locale: "es-CO",
load: "load"
});
grid.appendTo("#grdBeneficiarios");
},
error: function (jqXHR, textStatus, error) {
alert(error);
}
});
but I am getting an error in javascript, image attached.
Second question: Is there any way to manage remoteserveradapter in javascript ( no textscript) ?
Attachment: Error_b41c1e66.zip
SIGN IN To post a reply.
3 Replies
MS
Madhu Sudhanan P
Syncfusion Team
March 13, 2019 06:08 AM UTC
Hi Juan,
Thanks for contacting Syncfusion support.
Query 1 : I am getting an error in javascript, image attached.
We have analyzed the codes which you have shared with us. We could see that you have not defined the handler function for the “load” event which you have bind to Grid. This is the cause of the error you are facing. We suggest you to define a handler function for the load event as like the code below. And also ensure to use proper naming case for the “dataSource” property.
|
$.ajax({
...
success: function (result) {
...
var grid = new ej.grids.Grid({
dataSource: result.listaBeneficiarios,
...
locale: "es-CO",
load: function (args) {
console.log("Need to define the load event handler");
}
});
grid.appendTo("#grdBeneficiarios");
},
...
});
|
Documentations :
Query 2 : Is there any way to manage remoteserveradapter in javascript ( no textscript) ?
Based on your requirement we have prepared a “RemoteSaveAdaptor” sample with JavaScript(ES5) code. Please download the sample from the link below,
Sample : http://www.syncfusion.com/downloads/support/directtrac/general/ze/EJ2-dotnet-core1256166967
Please refer the code below,
|
<div id="Grid"></div>
<script>
var data = @Html.Raw(Json.Serialize(ViewBag.DataSource));
var dataSource = new ej.data.DataManager({
json: data,
adaptor: new ej.data.RemoteSaveAdaptor(),
insertUrl: '/Home/Insert',
updateUrl: '/Home/Update',
removeUrl: '/Home/Delete'
});
var grid = new ej.grids.Grid({
dataSource: dataSource,
...
});
grid.appendTo("#Grid");
</script>
|
Please get back to us if you need further assistance.
Regards,
Madhu Sudhanan P
JJ
Juan José
March 14, 2019 06:56 PM UTC
Thanks so much,
Now it is working
MS
Madhu Sudhanan P
Syncfusion Team
March 15, 2019 05:21 AM UTC
Hi Juan,
Thanks for the update.
Regards,
Madhu
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
JJ Juan José
- Mar 12, 2019 05:27 AM UTC
- Mar 15, 2019 05:21 AM UTC