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
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.
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": [
{ ... },
{ ... }
]
}
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.
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
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.
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?
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.
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.
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.
Hi Anton,
Could you please create a simple demo with OData aggregations and Kendo Grid?
Thanks,
Oleg.
@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.