1

我知道您可以使用 Jquery 中的数据对象在 HT 中放置复选框,如此处所示我想知道如果数据在数组中,您是否可以制作一个复选框单元格。数据样本如下:

var data = [
          ["", "Maserati", "Mazda", "Mercedes", "Mini", "Mitsubishi"],
          ["2009", 0, 2365, 4303, 354, 5814],
          ["2010", 5, 2905, 2867, 412, 5284],
          ["2011", 4, 2517, 4822, 552, 6127],
          ["2012", 2, 2422, 5399, 776, 4151]
        ];

取自 HT 样本。

4

1 回答 1

0

是的,您可以使用带有handsontable 的复选框列。复选框为真或假。您的示例数据中的所有列/值都不是真/假。

有关如何使用复选框列的更多详细信息,请参见此处的示例

简而言之,您需要确保该列具有如下的真/假值:

var data = [
  {id: 1, name: "Ted", isActive: true, color: "orange", date: "2008-01-01"},
  {id: 2, name: "John", isActive: false, color: "black", date: null},
  {id: 3, name: "Al", isActive: true, color: "red", date: null},
  {id: 4, name: "Ben", isActive: false, color: "blue", date: null}
];

然后将列类型设置为复选框:

  columns: [
    {data: "id"},
    {data: "name"},
    {data: "isActive", type: 'checkbox'},
    {data: "date", type: 'date'},
    {data: "color",
      type: 'autocomplete',
      source: ["yellow", "red", "orange", "green", "blue", "gray", "black", "white"]
    }
  ],
于 2013-06-27T23:51:03.593 回答