Grouping not working
When trying to do serverside grouping I get the following JS error:
kendo.all.js:69687 Uncaught TypeError: Cannot read property 'length' of undefined
at init._rowsHtml (kendo.all.js:69687)
at init._groupRowHtml (kendo.all.js:69772)
at init._renderContent (kendo.all.js:70517)
at init.refresh (kendo.all.js:70340)
at init.e (jquery-3.1.1.min.js?v=HPMOWdIdSuVgr3FD9ZE-_MgiK8qk_MdQjrgCtfqp6U4:2)
at init.trigger (kendo.all.js:164)
at init._process (kendo.all.js:7994)
at init.success (kendo.all.js:7690)
at success (kendo.all.js:7581)
at Object.n.success (kendo.all.js:6452)
That's the datasource:
var dataSource = {
schema:
{
data: "Data",
total: "Total",
aggregates: "Aggregates",
groups: "Groups",
errors: "Errors"
},
transport: {
read: {
url: 'xxx',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
type: 'POST'
},
parameterMap: function (data) {
return JSON.stringify(
{
dataSourceRequest: data
});
}
},
pageSize: 50,
serverPaging: true,
serverFiltering: true,
serverSorting: true,
serverGrouping: true
}
I'm using Kendo.DynamicLinqCore 3.1.1 and Telerik.UI.for.AspNet.Core 2020.3.1021. Am I missing something?
I encountered this as well when pulling data from a legacy WCF service. The error I'm seeing in my WCF service traces is: System.Runtime.Serialization.InvalidDataContractException: No set method for property 'Field' in type 'Kendo.DynamicLinqCore.GroupResult'.
To get around this, I changed the return type of my WCF method from DataSourceResult to string and used Newtonsoft.Json.JsonConvert.SerializeObject to generate the JSON instead of the built-in WCF serializer. I also had to create a custom Newtonsoft.Json.JsonConverter class to massage the GroupResult object into something that my Kendo grid could parse and display correctly:
public class GroupResultConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var typedValue = (GroupResult)value;
var result = new {
aggregates = typedValue.Aggregates ?? new object[0],
field = typedValue.SelectorField,
hasSubgroups = typedValue.HasSubgroups,
items = typedValue.Items,
total = typedValue.Count,
value = typedValue.Value
};
serializer.Serialize(writer, result);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override bool CanConvert(Type objectType)
{
return objectType == typeof(GroupResult);
}
}
When trying to do serverside grouping I get the following JS error:
kendo.all.js:69687 Uncaught TypeError: Cannot read property 'length' of undefined at init._rowsHtml (kendo.all.js:69687) at init._groupRowHtml (kendo.all.js:69772) at init._renderContent (kendo.all.js:70517) at init.refresh (kendo.all.js:70340) at init.e (jquery-3.1.1.min.js?v=HPMOWdIdSuVgr3FD9ZE-_MgiK8qk_MdQjrgCtfqp6U4:2) at init.trigger (kendo.all.js:164) at init._process (kendo.all.js:7994) at init.success (kendo.all.js:7690) at success (kendo.all.js:7581) at Object.n.success (kendo.all.js:6452)That's the datasource:
var dataSource = { schema: { data: "Data", total: "Total", aggregates: "Aggregates", groups: "Groups", errors: "Errors" }, transport: { read: { url: 'xxx', dataType: 'json', contentType: 'application/json; charset=utf-8', type: 'POST' }, parameterMap: function (data) { return JSON.stringify( { dataSourceRequest: data }); } }, pageSize: 50, serverPaging: true, serverFiltering: true, serverSorting: true, serverGrouping: true }I'm using Kendo.DynamicLinqCore 3.1.1 and Telerik.UI.for.AspNet.Core 2020.3.1021. Am I missing something?
This library is for Kendo UI for JQuery, so I didn't test it on Telerik.UI.for.AspNet.Core. I suggest you can check your server response data first.
I managed to make it work by Replacing the DataMember by JsonPropertyName. More info here: https://github.com/dotnet/aspnetcore/issues/14158