Kendo grid, odata v4, grouping - e.slice is not a function

13 posts, 0 answers
  1. balazs
    balazs avatar
    13 posts
    Member since:
    Dec 2014

    Posted 21 Sep 2015 Link to this post

    Grouping in kendo grid does not work, v2015.02.805.

    Got JS error: e.slice is not a function.

     Actually with the code below I can overcome this issue, but it's only a hack to a bug, since the result from odata v4 is defined and grid/binding should do the rest.

     

                var dataSource = new kendo.data.DataSource({
                    type: "odata-v4",
                    transport:
                    {
                        read:
                        {
                            url: '/odataquery/AutoZnackaModelView',
                            dataType: "json"
                        },
                        schema: {
                            data: function(data) {
                                return data["value"];
                            },
                            group: function(data) {
                                return data["value"];
                            },
                            total: function(data) {
                                return data["odata.count"];
                            }
                        },
                        error: function() { console.log(arguments); },
                        pageSize: 5,
                        serverPaging: true,
                        serverFiltering: true,
                        serverSorting: true,
                        serverGrouping: true
                    }
                });

  2. balazs
    balazs avatar
    13 posts
    Member since:
    Dec 2014

    Posted 21 Sep 2015 in reply to balazs Link to this post

    Sorry, the only way to override this buggy behaviour is to set FALSE on server grouping inside the datasurce.
  3. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 23 Sep 2015 Link to this post

    Hi Balazs,

    This JS error usually occurs when the DataSource is unable to locate the set of data in the response. That is why you need to set the schema properties. It seems like you do not need to set them as functions, since these are simple properties of the response, you can try with:

    schema: {
        data: "value",
        total: "odata.count"
    }

    Additionally, can you confirm that the data you return from the server is indeed grouped? If not, you should not set the serverGrouping property to true, as the DataSource will expect grouped response in situations where grouping is applied on the client. If your web service can't return grouped data when requested, serverGrouping must be set to false

    Regards,
    Tsvetina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  4. balazs
    balazs avatar
    13 posts
    Member since:
    Dec 2014

    Posted 23 Sep 2015 in reply to Tsvetina Link to this post

    Hi, Tsvetina,

    what do you mean data from server grouped? how those data structure should look like? since even if grouped odata v4 will first include grouped data but the structure will still be:

    {

    "odata.count" : 

    "values": [

              { ... },

              { ... }
         ]

    }

  5. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 28 Sep 2015 Link to this post

    Hi Balazs,

    What I was asking was whether your end point performs grouping on data, when it is passed a group-by parameter? Is the data in the response grouped? If not, you should set serverGrouping to false. 

    You can reproduce the same behavior in this sample if you set server grouping to true and try grouping the Grid:
    http://dojo.telerik.com/UKaTo

    Since the web service doesn't perform grouping when a group-by parameter is passed, then grouping must be left for the DataSource to handle on the client.


    Regards,
    Tsvetina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  6. balazs
    balazs avatar
    13 posts
    Member since:
    Dec 2014

    Posted 03 Oct 2015 in reply to Tsvetina Link to this post

    I've got the following odata v4 call, which returns data. 

    The data source type is set to: "odata-v4"

    Returned data sample:

    {

    "@odata.context":"http://localhost:2755/odataquery/$metadata#UserActivityView",

    "@odata.count":10,

    "value":[

         { "UserDataId":2,"Version":1,"UserTrackingId":"396766a5-3534-4382-8423-1630e2b1ee92","Typ":1," },

         { ...

     ​

    URL:

    http://localhost:2755/odataquery/UserActivityView?%24format=json&%24top=20&group%5B0%5D%5Bfield%5D=UserTrackingId&group%5B0%5D%5Bdir%5D=asc&%24count=true

     

    Error I got:

    Uncaught TypeError: Cannot read property 'length' of undefined

  7. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 07 Oct 2015 Link to this post

    Hello Balazs,

    Sorry, you were correct about the schema settings. Since it is odata-v4 type, you do not need to set neither the data, nor the total properties of the DataSource. They are automatically set by the DataSource.

    So, I tested the same scenario with an OData v4 endpoint and again, I get the "e.slice...." error when I trigger a grouping on the client, with enabled serverGrouping on an endpoint that doesn't support grouping. 

    So, as a conclusion—you don't need to make any schema settings and you need to disable server grouping, unless you implement grouping in your endpoint.

    Regards,
    Tsvetina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  8. balazs
    balazs avatar
    13 posts
    Member since:
    Dec 2014

    Posted 04 Nov 2015 in reply to Tsvetina Link to this post

    Can you please give an odata-v4 URL which supports grouping?

    Also can you describe what is differrent (in the returned data) if the grouping is enabled on the odata endpoint?

  9. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 06 Nov 2015 Link to this post

    Hello Balazs,

    We don't have a specific example service using OData-v4 with remote grouping. But you can see a description of the response structure that the DataSource would be able to parse, when remote grouping is enabled, here:
    DataSource Groups Format (runnable sample with hard-coded data available here)

    As the documentation states, if data can't be returned in this format by the service, you can provide a function to schema.groups that parses the data and returns the groups in the required format.

    Regards,
    Tsvetina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  10. Oleg
    Oleg avatar
    2 posts
    Member since:
    Jul 2016

    Posted 15 Jul in reply to Tsvetina Link to this post

    Hello Tsvetina,

     

    Does Kendo UI grid supports OData aggregations?

    https://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs01/odata-data-aggregation-ext-v4.0-cs01.html

     

    Thanks,

    Oleg.

  11. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 20 Jul Link to this post

    @Oleg

    This should be handled by the Kendo UI Data source component that provides an abstraction over the oData service.

    You can see a demo here.  More configuration options are available here.

    For more technical inquiries about the Kendo UI Grid widget included in the Kendo UI Professional product I'd suggest consulting the respective product forums here or the community forums.

    Regards,
    Anton Dobrev
    Telerik by Progress
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  12. Oleg
    Oleg avatar
    2 posts
    Member since:
    Jul 2016

    Posted 20 Jul in reply to Anton Dobrev Link to this post

    Hi Anton,

     

    Could you please create a simple demo with OData aggregations and Kendo Grid?

     

    Thanks,

    Oleg.

  13. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 25 Jul Link to this post

    Hi,

    @Oleg

    Unfortunately, we do not have such demo and I am afraid that we cannot provide a resolution for your technical question in regard to Kendo UI Grid.

    As far as I am aware, the Kendo UI Data Source component has a partial support (as shown here), but not in its entirety, for working with oData v4.

    Please follow my suggestion and consult the respective product and/or community forums.

    Thanks for your understanding.

    Regards,
    Anton Dobrev
    Telerik by Progress
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top