Kendo - 网格 - 聚合页脚列对齐

时间:2012-11-15 21:18:06

标签: grid alignment aggregate show-hide kendo-ui

我有一个Kendo Grid,它有一个页脚模板来显示汇总数据。聚合数据最初与其列对齐(就像它应该的那样)。但是,如果我隐藏列并且列具有不同的宽度,则聚合数据将与其列不对齐。这是小提琴:http://jsfiddle.net/uQG2J/1/

以下是代码:

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();

如何在隐藏另一列后将聚合数据与其列对齐?

1 个答案:

答案 0 :(得分:0)

为避免这种情况,请将列的宽度设置为百分比。

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();

以下是更新的jsfiddle