Slickgrid 不会在 table / Grid 中呈现或填充 JSON 数据

Slickgrid does not render or populate the JSON data in table / Grid

下面是我使用的columnsobject

 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);
}

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

代码

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

我已经使用您在问题中提到的设置快速为您制作了一个 JSFiddle

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

因此,请使用 : 而不是 id 字段声明中的 ,


例如您有:

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

相反,您需要:

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