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

[Solved] Update Footer Template of Column with ClientTemplate

2 Answers 973 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tiago
Top achievements
Rank 2
Tiago asked on 16 Oct 2014, 05:28 PM
<%    this.Html.Kendo().Grid<EditablePlanejamentoDescarga>()
                     .Name("GridPlanejamento")
                     .Columns(columns =>
                     {
                         columns.Bound(c => c.TransportadorNome)
                                .Width(500)
                                .HeaderHtmlAttributes(new { style = "text-align: center; font-weight: bold" })
                                .ClientFooterTemplate(" TOTAIS :")
                                .FooterHtmlAttributes(new { style = "background-color:lightgray; text-align: right; font-weight :bold" });
                         columns.Bound(c => c.Domingo)
                                .Width(175)
                                .HtmlAttributes(new { style = "text-align: center" })
                                .HeaderHtmlAttributes(new { style = "text-align: center; font-weight: bold" })
                                .ClientTemplate("#= Domingo.QuantidadeFardos >0 ? Domingo.QuantidadeFardos :'' #")
                                .ClientFooterTemplate("#=sum#")
                                .FooterHtmlAttributes(new { style = "background-color:lightgray; text-align: right; font-weight :bold" });
                         columns.Bound(c => c.SegundaFeira)
                                .Width(175)
                                .HtmlAttributes(new { style = "text-align: center" })
                                .HeaderHtmlAttributes(new { style = "text-align: center; font-weight: bold" })
                                .ClientTemplate("#= SegundaFeira.QuantidadeFardos >0 ? SegundaFeira.QuantidadeFardos :'' #")
                                .ClientFooterTemplate("#=sum#")
                                .FooterHtmlAttributes(new { style = "background-color:lightgray; text-align: right; font-weight :bold" });
                         columns.Bound(c => c.TotalTransportador)
                                .HtmlAttributes(new { style = "background-color:lightgray; text-align: right; font-weight :bold" })
                                .HeaderHtmlAttributes(new { style = "text-align: center; font-weight: bold" })
                                .ClientTemplate("#= TransportadorNome == '' ? '' : TotalTransportador #")
                                .ClientFooterTemplate("#=sum#")
                                .FooterHtmlAttributes(new { id = "footerTotal", style = "background-color:lightgray; text-align: right; font-weight :bold" });
                     })
                     .DataSource(dataSource =>
                     {
                         dataSource.Ajax().Batch(true).ServerOperation(false);
                         dataSource.Ajax().Model(m =>
                         {
                             m.Id(i => i.TransportadorNome);
                             m.Field(f => f.TransportadorNome).Editable(false);
                             m.Field(f => f.TotalTransportador).Editable(false);
                         });
                         dataSource.Ajax().Aggregates(agg =>
                         {
                             agg.Add(a => a.Domingo.QuantidadeFardos).Sum();
                             agg.Add(a => a.SegundaFeira.QuantidadeFardos).Sum();
                             agg.Add(a => a.TotalTransportador).Sum();
                         });
                         })
                     .ToolBar(toolbar =>
                     {
                         toolbar.Save();
                     })
                     .Editable(e => e.Mode(Kendo.Mvc.UI.GridEditMode.InCell))
                     .Navigatable(n => n.Enabled(true))
                     .Events(e => e.DataBound("onDataBound").Edit("onEdit").Save("onSave"))
                     .Render();
           %>


For columns c.Domingo and c.SegundaFeira the agg.Add(a => a.Domingo.QuantidadeFardos).Sum() and agg.Add(a => a.SegundaFeira.QuantidadeFardos).Sum() don't works.
I'm using a .ClientTemplate("#= SegundaFeira.QuantidadeFardos >0 ? SegundaFeira.QuantidadeFardos :'' #") to show cell value.
JavaScritp erro occours ' sum' is undefined.


But  for the c.TotalTransportador  columns works correctly.

Thanks,

Tiago.








2 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 20 Oct 2014, 03:11 PM
Hi Tiago,

Looking at the snippet you have provided, it suspect that the issue is caused by the fact that the column field and the DataSource aggregated field does not match. In order to correct this you could either change the field to which the column is bound (this may not work in older versions of the library), for example:

columns.Bound(c => c.Domingo.QuantidadeFardos)

or change the ClientFooterTemplate:

.ClientFooterTemplate(""#=data['Domingo.QuantidadeFardos'].sum#")


Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Tiago
Top achievements
Rank 2
answered on 20 Oct 2014, 04:01 PM
Thanks, worked properly.

Tags
Grid
Asked by
Tiago
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Tiago
Top achievements
Rank 2
Share this question
or