【发布时间】:2018-05-07 19:29:53
【问题描述】:
我需要一些工作帮助。故事是这样的:
如果 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 的函数。
【问题讨论】:
-
我觉得你想做的应该很简单,但是你的代码示例看起来有点糊涂...
标签: javascript angular typescript ag-grid