Error "Uncaught TypeError: Unable to read property" __count "from undefined" in network data source

I recently updated the version of jQuery and Kendo UI. Now using jQuery 12/12/13 and Kendo UI 2016.3.914 (don't know which version matches on their public website, but probably around R3 2016).

It seems that kendo or jQuery have become tougher in terms of data formats. I had a kendo user interface grid with a data source that I had type: "json". This worked in earlier versions, but was no longer - he 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 through the documentation and changed the type odata. This gave an error:

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

Typical of the Kendo user interface, this error message does not really tell you much. So what's wrong?

+4
source share
2 answers

It turned out that somehow the determining type as odataexpected that the data data data contain information about the size of the results. I tried adding a definition to the schemagrid:

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

But it did not help.

In the end, that helped to completely remove the definition type. So, now my grid data source has no explicit definition type, but it works fine.

+1
source

I added the following code to the data source schema and got this thing to work without deleting the type odata.

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

         }

        }

Solution found in this link.

0
source

Source: https://habr.com/ru/post/1659031/


All Articles