1
我正在extjs4 MVC加yii框架工作。我被困在一個點,這是如何訪問來自服務器的jason文件中的額外參數,並在extjs4中處理它到客戶端。 我的代碼: - 1)我的JSON文件是: -如何訪問extjs4中的json文件中的額外參數?
{
'users': [
{
"userId": 1,
"userName": 'Who will win the series11111111?',
"message":"You are welcome",
}
]
}
2)我的usermodel類在extjs4: - 在此文件中沒有任何 '信息' 屬性提供。
Ext.define('Balaee.model.sn.UserModel',{
extend: 'Ext.data.Model',
fields: ['userId','userName','password'],
proxy:
{
type:'ajax',
api:
{
read:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/AuthenticateLogin',
create:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/AuthenticateLogin',
},//end of api
reader:
{
type:'json',
root:'users'
},//end of reader
writer:
{
type:'json',
root:'records',
},//End of writer
}//end of proxy
});
3)這裏是我的視圖文件,我要訪問來自json文件的用戶名和消息字段。
Ext.define('Balaee.view...',
{
extend:'Ext.view.View',
store:'kp.UserStore',
config:
{
tpl:'<tpl for=".">'+
'<div id="main">'+
'</br>'+
'<b>userName :-</b> {userName}</br>'+
'<b>message :-</b> {message}</br>'+
'</div>'+
'</tpl>',
itemSelector:'div.main',
}
});// End of login class
但它不工作,它顯示userName字段值但不顯示消息字段值。
其實我想訪問extjs4模型類中不存在的消息字段。訪問這種沒有任何關係的字段是否正確?我怎樣才能訪問這種類型的字段。請給我一些建議。
感謝您reply.This變化解決了問題,但是否有其他方式來訪問此類型沒有包含在模型字段中的字段? –