2

嗨朋友们。我backgrid在我的项目中使用。我想隐藏 Id 列backgrid。这是我的代码。

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 }
];
4

3 回答 3

6

add a renderable: false attribute. See renderable here http://wyuenho.github.io/backgrid/api/index.html#!/api/Backgrid.Column

于 2014-04-25T01:13:44.357 回答
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 }];
于 2014-04-19T14:29:01.117 回答
0

属性 renderable: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 }
];
于 2016-12-09T18:29:04.273 回答