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

Aggregate Sum Using VB.net

1 Answer 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 23 Feb 2014, 04:49 AM
I thought I had this but I think I'm missing something.

I think I read somewhere FooterTemplate doesn't work.  Is this correct?

I can count using ClientFooterTemplate, but when I sum the value appears to be concatenating.

Any assistance would be helpful.  Thanks in advance.

Here's what I have:

<div>
    @(Html.Kendo.Grid(Of Venable.KMVC.ClientPortfolio.ADRServiceReference.Activity)() _
            .Name("clientActivityYear") _
            .Events(Sub(e)
                            e.DataBound("onDataBound").Change("onChange")
                    End Sub) _
            .Columns(Sub(c)
                             c.Bound(Function(p) p.Year).FooterTemplate("LTD")
                             c.Bound(Function(p) p.WorkedActivity).Title("Worked").HtmlAttributes(New With {.style = "text-align: right"}).ClientFooterTemplate("#=sum#")
                             c.Bound(Function(p) p.BilledActivity).Title("Billed").HtmlAttributes(New With {.style = "text-align: right"})
                             c.Bound(Function(p) p.CollectedActivity).Title("Collected").HtmlAttributes(New With {.style = "text-align: right"})
                     End Sub) _
        .Selectable(Function(selectable) selectable.Mode(GridSelectionMode.Single)) _
        .Scrollable() _
        .DataSource(Sub(d)
                            d.Ajax().ServerOperation(False).Aggregates(Sub(aggregates)
                                                                               aggregates.Add(Function(p) p.WorkedActivity).Sum()
                                                                               aggregates.Add(Function(p) p.BilledActivity).Sum()
                                                                               aggregates.Add(Function(p) p.CollectedActivity).Sum()
                                                                       End Sub) _
                            .Read(Function(read) read.Action("ActivityRead", "Home").Data("addData"))
                    End Sub)
     )
</div>

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 26 Feb 2014, 07:52 AM
Hi Mike,

Basically the difference between a Template and ClientTemplate is where it is executed. As the name suggests, the client template is rendered on the client-side and uses Kendo UI template syntax. In contrast, the FooterTemplate is executed on the server and uses Razor (or ASPX) syntax. Since the Grid uses Ajax instead of Server binding I would recommend using client templates.
Regarding your second question - the Sum aggregate will concatenate the values in case they are not of numeric type, and this is the expected behavior.  

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or