嗨朋友们。我在我的项目中使用backgrid
。我想隐藏backgrid
的Id列。这是我的代码。
var columns = [
{ name: "id", label: "Id", cell: "integer", editable: false },
{ name: "payment_date", label: "Payment Date", cell: "date" ,editable: false },
{ name: "number_of_task", label: "Total Task", cell: "integer" ,editable: false },
{ name: "amount", label: "Amount", cell: "integer" ,editable: false }
];
答案 0 :(得分:6)
添加renderable: false
属性。请参阅此处可渲染http://wyuenho.github.io/backgrid/api/index.html#!/api/Backgrid.Column
答案 1 :(得分:0)
只需删除列定义即可。您不需要为数据中的每个addribute添加列定义;您只需要要在表中显示的属性的列定义。
var columns = [
{ name: "payment_date", label: "Payment Date", cell: "date" ,editable: false },
{ name: "number_of_task", label: "Total Task", cell: "integer" ,editable: false },
{ name: "amount", label: "Amount", cell: "integer" ,editable: false }];
答案 2 :(得分:0)
属性可渲染:false对我不起作用因此在下面用作解决方法
var HideCell = Backgrid.HideCell = Backgrid.Cell.extend({
/** @property */
className: "hide-cell",
initialize: function () {
Backgrid.Cell.prototype.initialize.apply(this, arguments);
},
render: function () {
this.$el.hide();
return this;
}
});
在列中用作单元格“隐藏”
var columns = [
{ name: "id", label: "Id", cell: HideCell, editable: false }
];