1

我正在使用 grid.js 库,但是在向表中添加数据时,我没有看到 rowId 出现,所以我无法处理行的颜色变化并通过单击“双铅笔”来获取行的数据通过 rowId 的图标(事件 onClick)。现在我想为 1 行添加 rowId。帮我。谢谢

    columns: [
      {
        id: "update",
        name: "update",
        width: "3%",
        align: "center",
        sort: {
          enabled: false,
        },
        formatter: (cell, row, column) => {
          rowObject = {
            Id: row.cells[6].data,
            Name: row.cells[2].data,
          };
          return gridjs.html(
            `<i class="bi bi-pencil-square fs-5" role="button" onclick='setValue(${JSON.stringify(
              rowObject
            )})'></i>`
          );
        },
      },
      {
        id: "short-name",
        name: "Short name",
        width: "47%",
      },
      {
        id: "full-name",
        name: "Full name",
      },
      {
        id: "id",
        name: "id",
        hidden: true,
      },
    ],
    sort: true,
    pagination: {
      limit: 16,
    },
    server: {
      method: "GET",
      url: "/getData",
      then: function (data) {
        loadDataCombobox(data.records);
        return data.records.map(function (col) {
          return [
            null,
            col.shortName,
            col.fullName,
            col.id,
          ];
        });
      },
    },
  }).render(document.getElementById("area-table"));
}
4

0 回答 0