如何添加一列显示小尺寸的图像在背景网格内。

2024-06-25 07:14:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在backgrid中添加一个列字段来显示img和其他与该用户相关的信息。在

var columns = [

    { name: "id", label: "Id", cell: "integer",editable: false },

    { name: "active_image", label: "Image", cell: "uri",editable: false },

    { name: "worker_id", label: "Worker", cell: "string",editable: false },

    { name: "city", label: "City", cell: "string",editable: false }

    ];

Tags: columns用户name信息idfalseimgstring
1条回答
网友
1楼 · 发布于 2024-06-25 07:14:36

我建议你输入新的单元格图像。然而,最简单的解决方案是扩展基本Backgrid.Cell

{
  name: 'active_image',
  label: 'Image',
  editable: false,
  cell: Backgrid.Cell.extend({
    render: function() {
      var src = this.model.get(this.column.get('name'));
      this.$el.html($('<img>').attr('src', src));
      return this;
    }
  })
}

这里的render函数相当简化(并且没有经过测试),只是为了说明如何操作。

相关问题 更多 >