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

时间:2016-01-04 12:59:13

标签: javascript jquery json slickgrid populate

下面的

是我使用的let installation: PFInstallation = PFInstallation.currentInstallation() installation["user"] = PFUser.currentUser() installation.saveInBackground() 对象

columns

这是函数 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"} ] ,其中包含我尝试在网格中填充的示例JSON loadData()

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

1 个答案:

答案 0 :(得分:2)

我已经根据您在问题中提到的设置快速为您制作了JSFiddle

并且忽略了一个问题,当您创建JavaScript object时,您需要使用:作为分隔符你描述了你的键值对

因此,请使用:代替,字段声明中的id

作为一个例子,你有:

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

相反,你需要:

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