Dojo 网格中的复杂对象

发布于 2024-10-06 07:28:16 字数 828 浏览 3 评论 0原文

我想知道是否可以将以下对象填充到 dojo 网格中

首先,主对象是一个包含 3 个字段、2 个整数的对象数组和另一个包含 5 个字段的对象数组。我的问题是,我可以为 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}]}]

I want to know if its possible to populate the following object into a dojo grid

First off, the main object is a array of objects with 3 fields, 2 ints and ANOTHER ARRAY of objects with 5 fields. My question is, can I set-up a layout for the dojo grid to populate a grid with "subrows"

Here is a sample 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}]}]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光暖心i 2024-10-13 07:28:16

您可以使用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"));

You can use dojox.grid.TreeGrid, the layout looks like:

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"));
春风十里 2024-10-13 07:28:16

或者,如果您只想要一个包含一些子对象数据的单元格,您可以将格式化程序附加到单元格:

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

Or if you just want a single cell containing some child objects data, you can attach a formatter to a cell:

{ 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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文