我需要一些工作帮助。故事是这样的:
如果 Item-Id !== null; 我需要使“日期”列可编辑;
我们有一个“视图”,其中有一个使用 AG-Grid 创建的收件箱。
收件箱看起来像这样:
---| Item-Id | Date | Justification |---
----------------------------------------
---| |24.05 | text |---
----------------------------------------
---| 31 |25.05 | text 2 |---
----------------------------------------
---| 31 |25.05 | text 2 |---
----------------------------------------
---| |24.05 | text |---
----------------------------------------
---| |24.05 | text |---
----------------------------------------
---| 31 |25.05 | text 2 |---
----------------------------------------
要在 AG-grid 中生成列标题,您有一个对象:
public columnDefs = [
{title: Item-Id, editable: this.editable()},
{title: Date, editable: this.editable()},
{title: Justification, editable: this.editable()}
];
...一些代码...
在 Get 方法中我有这样的东西:
http.get(data).subscribe(response(
{
...some code...
this.editableColumns(response);
}));
public editableColumns(item: any) {
//this method need to return true or false;
console.log(response); // [{itemId: null, date: "24.05", justification: "text"},{itemId: 31, date: "24.05", justification: "text"},...etc...}]
}
我非常感谢你的帮助。
p.s:您不能使用诸如 column["editable"] = true; 之类的方法使单元格可编辑。这是行不通的。它必须是一个返回 true 或 false 的函数。