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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Got error building grid

Thread ID:

Created:

Updated:

Platform:

Replies:

143261 Mar 12,2019 05:27 AM UTC Mar 15,2019 05:21 AM UTC JavaScript - EJ 2 3
loading
Tags: Grid
Juan José
Asked On March 12, 2019 05:27 AM UTC

Hi, 
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

Madhu Sudhanan P [Syncfusion]
Replied On 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, 
 
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 


Juan José
Replied On March 14, 2019 06:56 PM UTC

Thanks so much,
Now it is working

Madhu Sudhanan P [Syncfusion]
Replied On March 15, 2019 05:21 AM UTC

Hi Juan, 
  
Thanks for the update. 
  
Regards, 
Madhu 


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

;