gpt4 book ai didi

javascript - Slickgrid 不会在表/网格中呈现或填充 JSON 数据

转载 作者:行者123 更新时间:2023-11-29 21:37:07 25 4
gpt4 key购买 nike

下面是我使用的对象

 columns =[
{id: "id", name: "ID", field: "id"},
{id: "rt_assignee", name: "rt_assignee", field: "root_task_assignee"},
{id: "root_task_id", name: "root_task_id", field: "root_task_id"},
{id: "root_task_status", name: "root_task_status", field: "root_task_status"},
{id: "root_task_tracker", name: "root_task_tracker", field: "root_task_tracker"},
{id: "rt_category", name: "rt_category", field: "rt_category"},
{id: "rt_priority", name: "rt_priority", field: "rt_priority"},
{id: "rt_subject", name: "rt_subject", field: "rt_subject"},
{id: "task_assignee", name: "task_assignee", field: "task_assignee"},
{id: "task_category", name: "task_category", field: "task_category"},
{id: "task_id", name: "task_id", field: "task_id"},
{id: "task_priority", name: "task_priority", field: "task_priority"},
{id: "task_status", name: "task_status", field: "task_status"},
{id: "task_subject", name: "task_subject", field: "task_subject"},
{id: "task_tracker", name: "task_tracker", field: "task_tracker"}
]

这是函数 loadData(),带有我尝试填充到网格中的示例 JSON data

function loadData() {
data = [{
"id", "issue_0",
"root_task_assignee": "reneym",
"root_task_id": 123808,
"root_task_status": "New",
"root_task_tracker": "Task",
"rt_category": "PPQA",
"rt_priority": "Normal",
"rt_subject": "95-00 Perform PPQA",
"task_assignee": "reneym",
"task_category": "PPQA",
"task_id": 123808,
"task_priority": "Normal",
"task_status": "New",
"task_subject": "95-00 Perform PPQA",
"task_tracker": "Task"
}];
dataView.setItems(data);
}

但没有输出,网格只是空白(但出现标题)。并且没有错误信息。

代码

loadData(); 
dataView.setGrouping([]);
dataView.endUpdate();
$("#gridContainer").resizable();

最佳答案

我很快就为你制作了一个 JSFiddle使用您在问题中提到的设置。

您遇到的和被忽视的问题是,当您创建 JavaScript object在描述您的键值对时,您需要使用: 作为分隔符

所以使用 : 而不是 , 你在你的 id 字段声明中。


举个例子:

data = [{   
"id", "issue_0",
...
}];

相反,您需要:

data = [{   
"id": "issue_0",
...
}];

关于javascript - Slickgrid 不会在表/网格中呈现或填充 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34591751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com