I was wondering how to hide/show columns based on the values of aggregate values in footer. For example:
@(Html.Kendo().Grid<Payroll.Models.PayrollAuthorizationByDepartmentModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(dataSource => dataSource.EmployeeId).Title("Emp. No");
columns.Bound(dataSource => dataSource.EmployeeNameForDisplay).Title("Emp. Name");
columns.Bound(e => e.RegHours).Title("Reg.")
.ClientFooterTemplate("<div style='text-align: right'> \\#= kendo.toString(sum, '0.00')\\# </div>")
.ClientTemplate("\\#= kendo.toString(RegHours, '0.00')\\#");
columns.Bound(e => e.OTHours).Title("OverTime 1.5")
.ClientFooterTemplate("<div style='text-align: right'> \\#= kendo.toString(sum, '0.00')\\# </div>")
.ClientTemplate("\\#= (OTHours==0)? '':kendo.toString(OTHours, '0.00')\\#");
})
.DataSource(dataSource => dataSource
.Ajax()
.Aggregates(aggregates =>
{
aggregates.Add(e => e.RegHours).Sum();
aggregates.Add(e => e.OTHours).Sum();
})
.Read(read => read.Action("AuthorizationByEmployee_Read", "Authorize", new { locationId = @ViewBag.LocationId, departmentId = "#=DepartmentId#", startDate = @ViewBag.StartDate, endDate = @ViewBag.EndDate }))
.ServerOperation(false)
.Sort(sort => sort.Add("EmployeeFirstName").Ascending())
)
.Sortable()
.Events(events => events.DataBound("onDataBoundOfChildGrid"))
.ToClientTemplate()
)
How to hide the column if the sum is 0?
Thanks!