Hide column based on values of footer

3 posts, 0 answers
  1. Stephen
    Stephen avatar
    6 posts
    Member since:
    Apr 2009

    Posted 13 Oct 2015 Link to this post

    I was wondering how to hide/show columns based on  the values of aggregate values in footer. For example:


    .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
    .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 }))
    .Sort(sort => sort.Add("EmployeeFirstName").Ascending())
    .Events(events => events.DataBound("onDataBoundOfChildGrid"))


    How to hide the column if the sum is 0?



  2. Kostadin
    Kostadin avatar
    1687 posts

    Posted 15 Oct 2015 Link to this post

    Hi Stephen,

    You can hide the column by using hideColumn method and pass the column name as an argument. A possible solution to access the aggregate is to get it from the  dataSource. Please check out the following code snippet.
    <script type="text/javascript">
        function onDataBound(arg) {
            var aggregates = arg.sender.dataSource.aggregates();
            if (aggregates.UnitsInStock.min == 0) {

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET AJAX banner
  4. Stephen
    Stephen avatar
    6 posts
    Member since:
    Apr 2009

    Posted 15 Oct 2015 in reply to Kostadin Link to this post

    Thank you. It works perfectly.
Back to Top