存储多级

发布于 2024-12-04 06:21:46 字数 1040 浏览 1 评论 0原文

我有以下 json :

{"service":
{"description":"Export a list of amendments.","id":"504e1bf57e8d2fdd92b6c316cd000b25","name":"AT4AM_AmendmentsList","notes":"Export a list of amendments in a defined format, Word or XML.\r\n\r\n\"keywords\" : [ \"AT4AM\", \"DST\", \"Amendment\", \"Export\", \"Word\", \"XML\" ]","revision":"2-cd375cfd296ba97e934f12794d4930e9","status":"study","type":"entity",
"versions":[{"description":"v1.0 description...","id":"504e1bf57e8d2fdd92b6c316cd0017c0","version":1}]}}

我想将版本列表显示到网格中。

这是我的模型:

Ext.define('XXXX.model.Version', {
extend: 'Ext.data.Model',
fields : [ {
    name : 'id',
    type : 'string'
}, {
    name : 'description',
    type : 'string'
}, {
    name : 'version',
    type : 'string'
}],
belongsTo: 'XXXX.model.Service',
proxy: {
    type: 'rest',
    id: 'id',
    url : 'http://localhost:8080/xxxxx/services/service',
    reader: {
        type: 'json',
        root: 'versions'
    }
}       

});

感谢您的帮助 混合泳

I have the following json :

{"service":
{"description":"Export a list of amendments.","id":"504e1bf57e8d2fdd92b6c316cd000b25","name":"AT4AM_AmendmentsList","notes":"Export a list of amendments in a defined format, Word or XML.\r\n\r\n\"keywords\" : [ \"AT4AM\", \"DST\", \"Amendment\", \"Export\", \"Word\", \"XML\" ]","revision":"2-cd375cfd296ba97e934f12794d4930e9","status":"study","type":"entity",
"versions":[{"description":"v1.0 description...","id":"504e1bf57e8d2fdd92b6c316cd0017c0","version":1}]}}

I would like to display the list of versions into a grid.

here is my model :

Ext.define('XXXX.model.Version', {
extend: 'Ext.data.Model',
fields : [ {
    name : 'id',
    type : 'string'
}, {
    name : 'description',
    type : 'string'
}, {
    name : 'version',
    type : 'string'
}],
belongsTo: 'XXXX.model.Service',
proxy: {
    type: 'rest',
    id: 'id',
    url : 'http://localhost:8080/xxxxx/services/service',
    reader: {
        type: 'json',
        root: 'versions'
    }
}       

});

Thanks for help
Medley

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

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

发布评论

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

评论(2

半步萧音过轻尘 2024-12-11 06:21:46

在阅读器的配置中使用 root: 'service.versions'

use root: 'service.versions' in your reader's config.

熟人话多 2024-12-11 06:21:46

这是我找到的解决方案:

1 - 我将其添加到模型“服务”中

{type: 'hasMany', model: 'XXXX.model.Version', name: 'versions'}

2 - 我使用配置的 RestProxy 发出 GET 请求

Ext.ModelManager.getModel('XXXX.model.Service').load(serviceId, {
            success: function(service) {
            // Now, it is possible to access to all the versions of a service
            service.versions().each(function(version) {
                    listOfVersions.push(version.data);
    });

}
});

问候
混合泳

Here is the solution I found :

1 - I added this to the model 'Service'

{type: 'hasMany', model: 'XXXX.model.Version', name: 'versions'}

2 - I used the configured RestProxy to make a GET request

Ext.ModelManager.getModel('XXXX.model.Service').load(serviceId, {
            success: function(service) {
            // Now, it is possible to access to all the versions of a service
            service.versions().each(function(version) {
                    listOfVersions.push(version.data);
    });

}
});

Regards
Medley

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