如何隐藏KoGrid中的列

时间:2013-12-12 11:51:53

标签: javascript jquery knockout.js kogrid

我已经开始使用koGrid了。我想在koGrid中隐藏一个特殊列'id'。我可以这样做吗?

 gridOptions : {
        displaySelectionCheckbox: false,
        data: items,
        multiSelect: false, 
        enableColumnResize: true,                
        columnDefs: [
                      { field: 'id', displayName: 'id' },
                      { field: 'name', displayName: 'Name' }

        ]
    }

1 个答案:

答案 0 :(得分:4)

您可以将visible option on the columnDefs设置为false

columnDefs: [
    { field: 'id', displayName: 'id', visible: false },
    { field: 'name', displayName: 'Name' }
]

或者,如果您在任何地方都不需要id值(因此您没有在模板中使用,或过滤排序等),您可以省略整个{ field: 'id', displayName: 'id' }