Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouping not working #17

Open
eloyrubio opened this issue Feb 4, 2021 · 3 comments
Open

Grouping not working #17

eloyrubio opened this issue Feb 4, 2021 · 3 comments

Comments

@eloyrubio
Copy link

eloyrubio commented Feb 4, 2021

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?

@dandrayan
Copy link

dandrayan commented Feb 9, 2021

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

@linmasaki
Copy link
Owner

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.

@eloyrubio
Copy link
Author

I managed to make it work by Replacing the DataMember by JsonPropertyName. More info here: dotnet/aspnetcore#14158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants