我的ExtJS模型定义如下:
Ext.define("WinEvents", {
extend: 'Ext.data.Model',
fields: ['eventName', 'domainId','eventId', 'proteanService', sviceId'],
hasMany: { model: 'WinServices', name: 'services'},
proxy: {
type: 'ajax',
method:'GET',
url : '../js/modules/tree_with_json/tree_model.json',
reader: {
type: 'json',
root: 'events'
}
}
});
这里,tree_model.json是带有suffix.json的空白文件 我命名为' selectedEventsServices'它的值是如下所示的json数据。
{
"domainID" : "CONSUMERTELEMATICS_0.1",
"domain" : "consumerTelematics",
"tenantId": "4"
"tenantName": "FOURRR"
"tenantOUId": "13"
"tenantOuName": "OSRTC Corp"
"events" : [{
"eventID" : "POS0.1",
"event" : "pos0.1",
"domainID" : "CONSUMERTELEMATICS_0.1",
"services" : [{
"proteanService" : "accident",
"serviceID" : "SER_0.1_1",
"domainID" : "CONSUMERTELEMATICS_0.1",
"proteanRelatedService" : null,
"eventID" : "POS0.1"
},{
"proteanService" : "assistanceService",
"serviceID" : "SER_0.1_2",
"domainID" : "CONSUMERTELEMATICS_0.1",
"proteanRelatedService" : null,
"eventID" : "POS0.1"
}]
}]
}

因此,如上所述,值是动态的,json结构化数据将保存到selectedEventsServices
变量。
现在问题是如何将selectedEventsServices
变量值写入tree_model.json
文件?
或者在本地调用Ext.data.Model
时是否有任何方法可以从变量中获取值?
答案 0 :(得分:0)
目前还不太清楚你到底想做什么。但是当然可以从变量创建模型。请查看手册Extjs.data.Model以获取示例:
var user = Ext.create('User', {
id : 'ABCD12345',
name : 'Conan',
age : 24,
phone: '555-555-5555'
});