0
votes

I have a Kendo Grid that has a footer template to show aggregate data. The aggregate data initially aligns with its column (just as it should). However, if I hide a column and the columns have different widths, the aggregate data becomes misaligned with its column. Here's the fiddle: http://jsfiddle.net/uQG2J/1/

Here's the code:

var grid = $("#grid").kendoGrid({
dataSource: {
    data: [
        {"foo": 10, "bar": 10, "moo":5},
        {"foo": 20, "bar": 30, "moo":8},
    ],   
    aggregate: [
       {field: "moo", aggregate: "sum"}
    ]
},
columns: [
    {
        field: "foo",
        width: 20
    },
    {
        field: "bar",
        width: 80            
    },       
    {
        field: "moo",
        footerTemplate: "Sum: #=sum# ",
        width: 40           
    }

]   
}).data("kendoGrid");

grid.hideColumn("foo");
grid.refresh();

How can I align the aggregate data with its column after hiding another column?

1

1 Answers

0
votes

To avoid this set the width of the columns in percents.

e.g.

var grid = $("#grid").kendoGrid({
    dataSource: {
        data: [
            {"foo": 10, "bar": 10, "moo":5},
            {"foo": 20, "bar": 30, "moo":8},
        ],    
        aggregate: [
           {field: "moo", aggregate: "sum"}
        ]
    },
    columns: [
        {
            field: "foo",
            width: "20%"
        },
        {
            field: "bar",
            width: "20%"
        },        
        {
            field: "moo",
            footerTemplate: "Sum: #=sum# ",
            width: "60%"
        }

    ]   
}).data("kendoGrid");

//grid.hideColumn("foo");
grid.refresh();

Here is an updated jsfiddle.