我想知道是否可以将以下对象填充到dojo网格
中首先,主要对象是一个对象数组,包含3个字段,2个整数和另外一个具有5个字段的对象的ARRHER ARRAY。我的问题是,我可以为dojo网格设置布局,用“子行”填充网格
以下是JSON示例
[{"ClaimID":1,"ClaimNumber":"4304021","LossDetails":[{"LossCause":"COLLISION ","LossDate":"\/Date(1136786400000-0600)\/",
"LossExpense":95.00,"LossPaid":6415.21,"LossReserve":0.00},{"LossCause":"BODILY INJURY ","LossDate":"\/Date(1136786400000-0600)\/",
"LossExpense":0.00,"LossPaid":250.00,"LossReserve":0.00},{"LossCause":"MEDICAL PAYMENTS ","LossDate":"\/Date(1136786400000-0600)\/",
"LossExpense":0.00,"LossPaid":0.00,"LossReserve":0.00},{"LossCause":"PROPERTY DAMAGE ","LossDate":"\/Date(1136786400000-0600)\/",
"LossExpense":0.00,"LossPaid":1893.99,"LossReserve":0.00}]}]
答案 0 :(得分:2)
您可以使用dojox.grid.TreeGrid
,布局如下:
new dojox.grid.TreeGrid({
structure: [
{ cells: [
[
{ field: "ClaimID", name: "ID" },
{ field: "ClaimNumber", name: "Number"},
{ field: "LossDetails",
children: [
{ field: "LossExpense", name: "LossExpense"},
{ field: "LossCause", name: "LossCause" },
{ field: "LossPaid", name: "LossPaid" },
{ field: "LossReserve", name: "LossReserve" },
{ field: "LossDate", name: "LossDate" }
]
}
]]
}
],
store: jsonStore,
queryOptions: {deep: true}
}, dojo.byId("grid"));
答案 1 :(得分:2)
或者如果您只想要一个包含一些子对象数据的单元格,您可以将格式化程序附加到单元格:
{ name: "Child data", field: "field_object", formatter: present_child_info}
...
function present_child_info(value) {
var s = "";
for(var i = 0; i < value.length; i++) {
s += value[i].attribute;
}
return s;
}