New
Last Updated: 30 Jan 2019 09:34 by ADMIN
n/a
Created on: 24 Jan 2019 16:57
Category: Grid
Type: Feature Request
0
ToDataSourceResult() method with DataTables for ASP.NET Core should support aggregates

Hi,

We have a property EnableHeaderContextAggregateMenu in Radgrid. By enabling this, we can aggregate any column in the Radgrid and show the result value in the corresponding column footer at runtime by the end user.

Do we have similar property in Kendo UI Grid? We need to implement this in Kendo UI Grid which has dynamic column data binding. We had attached a sample code here. Can you please implement the same in the code and revert?

Thanks & Regards,
Shivakumar. K

(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
5 comments
ADMIN
Alex Hajigeorgieva
Posted on: 30 Jan 2019 09:21
Hello, Shivakumar,

The item is now visible to the public as requested.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
n/a
Posted on: 29 Jan 2019 12:32

Hi,

Truly speaking, this could be a really useful feature for the end-users, if we allow them to do the necessary aggregration on their own at run-time instead of enforcing to do it in fixed manner.

You can proceed on this.

Thanks & Regards,
Shivakumar. K

ADMIN
Alex Hajigeorgieva
Posted on: 29 Jan 2019 11:14
Hello, Shivakumar,

Generally speaking, the features and enhancements are greatly dependent on customer demand. The higher the demand for a feature, the more likely it is to get in the current workflow of the team. (you may notice the Priority 1 tag of the issue - 5 is the highest priority)

I would suggest we make this thread public where more people will be able to see and upvote the idea. Once the idea is approved for implementation by the product management, the issue is assigned to a developer. This means we are currently working on it. Various tags and labels are added as the item progresses from development to quality assurance and into production. Finally, it will be tagged with a milestone, letting you know when you can expect it.

Let me know if this is ok with you and I will post this thread in our feedback portals.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
n/a
Posted on: 28 Jan 2019 13:03

Hi,

Do you have any idea on when the dynamic aggregation feature will be ready for use?

Thanks & Regards,
Shivakumar. K

ADMIN
Alex Hajigeorgieva
Posted on: 25 Jan 2019 12:59
Hi, Shivakumar,

Thank you very much for the provided code snippets.

The DataTable support for ASP.NET Core has actually been a little slow due to the framework taking its time to implement various aspects of it.
Microsoft initially did not port any extension methods which prevented the Kendo UI team to implement the aggregating functions.

I had a look at the Microsoft documentation and it looks like you can add the System.Data.DataSetExtensions.dll and use the AsEnumerable() method:

https://docs.microsoft.com/en-us/dotnet/api/system.data.datatableextensions.asenumerable?view=netframework-4.7.2#remarks

Doing so will allow you to define the data source aggregates, similar to the below:

.Aggregates(aggregates =>
{
    foreach (System.Data.DataColumn column in Model.Columns)
    {
        if (column.DataType == typeof(int))
        {
            aggregates.Add(column.ColumnName, typeof(int)).Sum();
        }
        if (column.DataType == typeof(string))
        {
            aggregates.Add(column.ColumnName, typeof(int)).Count();
        }
    }
})

Then use them in the footer/header templates, e.g:

.Columns(columns =>
{
    foreach (System.Data.DataColumn column in Model.Columns)
    {
        var c = columns.Bound(column.ColumnName);
        if (column.DataType == typeof(string)) {
            c.ClientFooterTemplate("count: #=count #");
        }
        if (column.DataType == typeof(int)) {
            c.ClientFooterTemplate("sum: #=sum #");
        }
    }
})

Finally, to make this possible, the controller code:

public IActionResult Read([DataSourceRequest] DataSourceRequest request)
{
    var res = GetDataTable(500).AsEnumerable().Select(x=> new {               
        Field1 = x.Field<string>("Field1"),
        Field2 = x.Field<int>("Field2")
    });
    return Json(res.ToDataSourceResult(request));
}

I am attaching here a sample project for your reference.

Finally, since the suggested approach takes away from the dynamic feature, I have logged an issue that you may follow at:

https://github.com/telerik/kendo-ui-core/issues/4798

Let me know if you have further questions.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Attached Files: