人人IT網

人人IT網

當前位置: 主頁 > 編程語言 > C >

ext Model裏面屬性是對象的解决方案

時間:2016-12-01 19:04來源:Internet 作者:Internet 點擊:
 像這種,model裏面屬性为對象的,可以這麼玩   方法一:   Ext.define('App.model.Model', { extend: 'E



 像這種,model裏面屬性为對象的,可以這麼玩

 

方法一:

 

   
			   Ext.define('App.model.Model', {
		            extend: 'Ext.data.Model',
// 		            requires: [
// 		                'App.model.Task'
// 		            ],
		            fields: [
		                {name: 'task' ,type:'auto'},
		                {name: 'task.createTime' ,mapping:'task.createTime'},
		                {name: 'processInstance'},
		                {name: 'processDefinition'},
		                {name: 'title', type: 'string'}
		            ]

		        });

 

{ header: '創建時間', dataIndex: 'task.createTime', align: 'center', flex:1}

 参考

http://stackoverflow.com/questions/10500367/extjs-model-fields-with-subfields 寫道
Thanks to @sha - here is the answer I needed :)

Model

fields:[

{name: 'id', type: 'int'},
{name: 'title', type: 'string'},
{name: 'description', type: 'string'},
{name: 'priority', type: 'auto'},
{name: 'code', type: 'string', mapping:'priority.code'},
{name: 'createdBy', type: 'auto'},

]
Gird Panel

columns:[

{header:'Title', dataIndex:'title', flex:1},
{header:'Description', dataIndex:'description'},
{header:'Priority', dataIndex:'code'}

],

 

 

 

 

 

如果,屬性是集合的,就用hasMany吧,

http://stackoverflow.com/questions/14756012/extjs-nested-model 寫道
 
Ext.define("ResponseModel",{
extend:'Ext.data.Model',
fields:[],

hasMany:[{
    model:'Sromain',
    name:'sromain'},{
    model:'Branch',
    name:'branches'}]});

Ext.define("Sromain",{
extend:'Ext.data.Model',
fields:['corporation','dbName','prijmyCelk','nakladyCelk','ziskCelk','neuhrVydCelk','neuhrPrijCelk','dph'],
belongsTo:'ResponseModel'});

Ext.define("Branch",{
extend:'Ext.data.Model',
fields:['branch_name','branch_code','strediskoprijmyCelk','strediskonakladyCelk','strediskoziskCelk','strediskoneuhrVydCelk','strediskoneuhrPrijCelk','streddphCelk'],
belongsTo:'ResponseModel'});

var firstRecord = store.getAt(0);
console.log(firstRecord.branches());

console.log(firstRecord.sromain());

 


From:ITEYE
頂一下
(0)
0%
踩一下
(0)
0%
------分隔線----------------------------
發表評論
請自覺遵守互聯網相關的政策法規,嚴禁發布色情、暴力、反動的言論。
評價:
表情:
驗證碼:點擊我更換圖片
欄目列表
推薦內容