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

The aggregates in the grid using tag helper

2 Answers 315 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Filip
Top achievements
Rank 1
Filip asked on 02 Jul 2018, 11:15 AM

Hi.

I've been trying for so long time to understand how to adjust an aggregate inside of a grid, but  I think I cannot to do this because of missing a documentation that could be helpful. I am not sure if it's possible for the actual moment or not, but I am trying to create an aggregate sum my columns ( Price/Quantity).

Any advice on how to do this?

<kendo-grid name="PartData"
            auto-bind="true">
    <datasource type="DataSourceTagHelperType.Custom"
                server-filtering="true"
                server-sorting="true">
        <transport>
            <read url="@Url.Action("OrderLines_Read", "Order", new { id = Model.Number })" />
        </transport>
        <aggregates>
            <aggregate field="Total" aggregate="sum"/>
            <aggregate field="ReservedAmount" aggregate="sum"/>
        </aggregates>
    </datasource>
    <columns>
        <column field="TotalPrice" title=" " hidden="true" html-attributes='new Dictionary<string, object> { ["class"] = "visible-xs-block" }' footer-template="<div>Total: #= sum #</div>" template="#=mobileTemplate(data)#"></column>
        <column field="PartNumber" title="Part Number" min-screen-width="767"></column>
        <column field="PartName" title="Name" min-resizable-width="767"></column>
        <column field="ReservedAmount" title="Quantity" footer-template="<div> #= sum #</div>"  width="100" min-screen-width="767"></column>
        <column field="TotalPrice" title="Price" footer-template="<div> #= sum #</div>" width="100" min-screen-width="767"></column>
    </columns>
</kendo-grid>

 

Thanks in advance

BTW, my an actual version of the library that I use - 2018.2.530

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 05 Jul 2018, 05:46 AM
Hello, Filip,

In general, the aggregate should be working as expected.

Please advise the end result that occurs? Is the footer template is not shown and the sum aggregate is 0?

Also, one of the aggregates is for field "Total", but there is no such field inside the Grid configuration. Please ensure that the names of the fields set inside the aggregates and the Grid are the same.

Additionally, share the .NET and Core version used in the project as this could be causing the unexpected result.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Filip
Top achievements
Rank 1
answered on 05 Jul 2018, 06:43 AM
Ehh, my mistake. It works as I suspected. I've forgotten to correct name of the field in the aggregates. Thanks for the reply I hope at least this post will be a tip to show how the aggregates work.
Tags
Grid
Asked by
Filip
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Filip
Top achievements
Rank 1
Share this question
or