最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error "Uncaught TypeError: Cannot read property '__count' of undefined" in grid d

programmeradmin2浏览0评论

I recently updated my jQuery and Kendo UI version. Now using jQuery 1.12.13 and Kendo UI 2016.3.914 (unsure which version it corresponds to in their public website, but probably around R3 2016).

It seems either kendo or jQuery have gotten more strict about data formats. I had a kendo UI Grid with a datasource which had type: "json". This worked in earlier versions but not anymore - it gave a warning:

Unknown DataSource transport type 'json'. Verify that registration scripts for this type are included after Kendo UI on the page.

So I looked at the documentation and changed the type to be odata. This gave an error:

VM94003:3 Uncaught TypeError: Cannot read property '__count' of undefined

Typical to Kendo UI, this error message really doesn't tell you much. So what is wrong?

I recently updated my jQuery and Kendo UI version. Now using jQuery 1.12.13 and Kendo UI 2016.3.914 (unsure which version it corresponds to in their public website, but probably around R3 2016).

It seems either kendo or jQuery have gotten more strict about data formats. I had a kendo UI Grid with a datasource which had type: "json". This worked in earlier versions but not anymore - it gave a warning:

Unknown DataSource transport type 'json'. Verify that registration scripts for this type are included after Kendo UI on the page.

So I looked at the documentation and changed the type to be odata. This gave an error:

VM94003:3 Uncaught TypeError: Cannot read property '__count' of undefined

Typical to Kendo UI, this error message really doesn't tell you much. So what is wrong?

Share Improve this question asked Oct 27, 2016 at 7:58 Lauri PeltonenLauri Peltonen 1,56215 silver badges31 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

I added the following code to schema of the dataSource and got this thing to work without removing type as odata.

schema: {
         data: function(data) {
              return data.value;
         },
         total: function(data) {
              return data['odata.count'];

         }

        }

The solution was found in this link

It turned out that somehow defining the type as odata expects that the datasource data includes information about the size of the results. I tried adding a definition in the schema of the grid:

total: function (data) {
    return data.length;
}

But this didn't help.

Eventually, what did help was taking off the type definition pletely. So now my grid's datasource has no explicit type definition but it seems to work just fine.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论