Premium forums

XML Binded Datasource with empty data doesn't work in Grid

  • Ingolf
    Ingolf avatar

    10 Jan 2012 (Link to this post)

    Hi,

    i have an virtual binded xml datasource in a grid. All works fine, but when the server has no records the browser has errors in Javascript because undefined values are in XML Data.

    Sample:
    <count>1</count><books><book><field1>Hallo</field1></book></books>  -> This works fine

    But if there are no books the browser reported errors:
    <count>0</count><books></books>  

    Browser message:Uncaught TypeError: Cannot read property 'field1' of undefined
  • Rosen
    Rosen avatar

    10 Jan 2012 (Link to this post)

    Hi Ingolf,

    I was able to observed the error you have described and we were able to address it. Therefore, I have attached an internal build which contains the fix. I have also updated your telerik points.

    Regards,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  • Ingolf
    Ingolf avatar

    10 Jan 2012 (Link to this post)

    Hi,

    thank you for your fast help.

    You have attached OpenSource Files. I use the commercial version. Is this the same? When not can you send me the commercial version Files.

    regards
    Ingolf
  • Rosen
    Rosen avatar

    11 Jan 2012 (Link to this post)

    Hi,

    Indeed, the files in both open source and commercial version are same.

    Greetings,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  • S
    S avatar

    17 Feb 2012 (Link to this post)

    Is there an updated version of the (code above - of xml grid example) for latest version of Kendo UI? This version doesnt work when latest kendo javascript files are embedded and newer version of jquery. I just get following error,

    Object doesn't support this action


                that.reader = new kendo.data.readers[options.schema.type || "json" ](options.schema);



  • Rosen
    Rosen avatar

    20 Feb 2012 (Link to this post)

    Hi,

    Could you please verify that you have included the kendo.data.xml file and all of the other dependencies are included correctly.

    Regards,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  • Roger
    Roger avatar
  • Adrian
    Adrian avatar

    31 May 2012 (Link to this post)

    I believe the error that people are still seeing, as well as me, has to do with an empty grid and the grid columns footerTemplate attribute with aggregate data functions (i.e. sum).  If I remove columns from the grid that contain aggregate data in the footerTemplate, the error goes away.
    Error messages I receive:
    • Uncaught TypeError: undefined has no properties
    • Uncaught TypeError: Cannot read property 'sum' of undefined
    In addition to this issue, is there a way to have a default display (i.e. "No records found") for an empty grid?

  • Adrian
    Adrian avatar

    31 May 2012 (Link to this post)

    I figured out a way around this error.  It involves doing a fetch on the the dataSource then checking the size (length) of the view:
    var ds = new kendo.data.DataSource({ ... });
    ds.fetch(function () {
        var dv = this.view();
        if (dv.length > 0) {
            var grid = $("#grid").kendoGrid({ ... }).data("kendoGrid");
        } else {
            alert("No records found");
        }
    });

Read FAQ or see Kendo UI in action!

Launch Demos