This is a migrated thread and some comments may be shown as answers.

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

12 Answers 491 Views
Report a bug
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
balazs
Top achievements
Rank 2
balazs asked on 21 Sep 2015, 10:07 AM

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
                }
            });

12 Answers, 1 is accepted

Sort by
0
balazs
Top achievements
Rank 2
answered on 21 Sep 2015, 10:21 AM
Sorry, the only way to override this buggy behaviour is to set FALSE on server grouping inside the datasurce.
0
Tsvetina
Telerik team
answered on 23 Sep 2015, 12:23 PM
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.

 
0
balazs
Top achievements
Rank 2
answered on 23 Sep 2015, 06:36 PM

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": [

          { ... },

          { ... }
     ]

}

0
Tsvetina
Telerik team
answered on 28 Sep 2015, 01:53 PM
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.

 
0
balazs
Top achievements
Rank 2
answered on 03 Oct 2015, 04:26 PM

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

0
Tsvetina
Telerik team
answered on 07 Oct 2015, 02:30 PM
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.

 
0
balazs
Top achievements
Rank 2
answered on 04 Nov 2015, 08:50 PM

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?

0
Tsvetina
Telerik team
answered on 06 Nov 2015, 04:20 PM
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.

 
0
Oleg
Top achievements
Rank 1
answered on 15 Jul 2016, 07:16 PM

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.

0
Anton Dobrev
Telerik team
answered on 20 Jul 2016, 07:08 AM
@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.

 
0
Oleg
Top achievements
Rank 1
answered on 20 Jul 2016, 07:55 AM

Hi Anton,

 

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

 

Thanks,

Oleg.

0
Anton Dobrev
Telerik team
answered on 25 Jul 2016, 02:16 PM
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.

 
Tags
Report a bug
Asked by
balazs
Top achievements
Rank 2
Answers by
balazs
Top achievements
Rank 2
Tsvetina
Telerik team
Oleg
Top achievements
Rank 1
Anton Dobrev
Telerik team
Share this question
or