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

Loading data in ejGrid

Hi,

I'm new developing under Syncfusion's Javascript controls.
This is my code for ejGrid object.

$("#clientesGrid").ejGrid({
          dataSource: dataManger,
          allowPaging: true,
          allowReordering: true,
          allowResizeToFit: true,
          allowSelection: false,
          pageSettings: { pageSize: 20 },
 
          columns: [
              { field: "Id", isPrimaryKey: true, type: "number", visible:false },
              { field: "RifOCedula", headerText: "RIF o Cédula", width: 100 },
              { field: "RazonSocialONombreYApellido", headerText: "Descripción", width: 100 },
              { field: "Direccion", headerText: "Dirección" },
              { field: "Email", headerText: "Correo Electrónico" }
          ],
          actionBegin: function (args) {
              args.model.query.addParams("searchValue", $("#searchValueText").val());
          }
      });
This is the response from the server:
{"$id":"1","value":[],"@odata.count":0}
This is the Console log (ej.grid.all.js (line 38495, col 47) using only ejGrid script non-minified:
TypeError: this.model.currentViewData is undefined
...s._dataSource() == null || this._dataSource().length == 0 || this.model.currentV...
If the initial response contains data, there is not error.

Thank you for your attention and support,
Alirio Castro


3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team February 22, 2016 09:58 AM UTC

Hi Alirio,

We are able to reproduce the reported issue at our end after binding the empty dataSource for the Grid via OdataV4Adaptor. We have created a new support incident under your account to track the issue “OdataV4Adaptor throws an script error after returning empty dataSource from server” and its status. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents

To work around this issue, create customAdaptor (extend the ej.OdataV4Adaptor) and return the processResponse function as result/count pair. Refer to the following code example.

<div id="Grid"></div>

<script type="text/javascript">

    $(function () {

        var customAdaptor = new ej.ODataV4Adaptor().extend({

            processResponse: function (data, ds, query, xhr, request, changes) {

                result = this.base.processResponse.apply(this, [data, ds, query, xhr, request, changes]);

                if (ej.isNullOrUndefined(result.count)) {

                    result.result = [];

                    result.count = result.result.length;

                }

                return result;

            }

        });

        var dataManager = new ej.DataManager({

            url: "/Odata/Orders/", adaptor: new customAdaptor()

        });

        $("#Grid").ejGrid({

            allowPaging: true,

            dataSource: dataManager,

              . . . . . .

        });

    });
</script>


We have prepared a sample that can be downloaded from the following location.

Sample: http://www.syncfusion.com/downloads/support/forum/122146/ze/EJGrid1022136248

Regards,
Seeni Sakthi Kumar S.


WO Wouter April 12, 2016 08:23 AM UTC

Often this._dataSource() has no property length, while this._dataSource has. I did a quick test with url & odatav4 adaptor, so I cant provide a complete example.


SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team April 13, 2016 10:33 AM UTC

Hi Alirio,

We have already created a new support incident under your account to track the issue “OdataV4Adaptor throws an script error after returning empty dataSource from server”. It has been fixed and included in the Essential Studio Volume 1, 2016 v14.1.0.41. Please log on to our support website and check it.

https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents

And we suggest to update to our latest version Essential Studio Volume 1, 2016 (v14.1.0.41) and is available for download under the following link:

1)      Install Essential Studio Essential Studio Volume 1, 2016 (v14.1.0.41) from the following link.


Essential Studio: http://www.syncfusion.com/forums/123633/essential-studio-2016-volume-1-release-v14-1-0-41-is-available-for-download


2)      Replace the Syncfusion dlls, scripts, CSS in your project from the following location.


Scripts and Css:  (Installed Location)\Syncfusion\Essential Studio\14.1.0.41\JavaScript\assets

Note: Clear browser cache and bin folders, after upgrading to the latest version to avoid the accidental reference of old scripts, CSS and dlls.

If you are still facing any difficulty, please provide the following information to analyze the issue and provide you solution as early as possible.

1)      Code example of Grid

2)      Stack trace of browser console (if any error)

3)      Exact Replication procedure for the issue

We have also prepared a sample with the latest version that can be referred from the following jsPlayground.

http://jsplayground.syncfusion.com/dkom12ic

Regards,
Seeni Sakthi Kumar S.


Loader.
Up arrow icon