简体   繁体   中英

Kendo - Grid - Aggregate Footer Column Alignment

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?

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

eg

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM