這裏呈現的是HTML文件的Src代碼GRID沒有正確的ExtJS 4使用存儲
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4 /strict.dtd">
<html>
<head>
<title>MVC Architecture</title>
<link rel="stylesheet" type="text/css" href="/bh/extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="extjs/ext-debug.js"></script>
<script type="text/javascript" src="Main.js"></script>
</head>
<body>
</body>
</html>
文件路徑:/bh/Main.js [主文件]
Ext.require('Ext.container.Viewport');
Ext.application({
name: 'App',
appFolder: 'app',
controllers: ['UserController'],
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'border',
items: [
{
xtype: 'userList'
}
]
});
}
});
文件路徑:/app/controller/UserController.js [控制器]
Ext.define('App.controller.UserController',{
extend: 'Ext.app.Controller',
stores: ['UserStore'],
models:['UserModel'],
views:['user.UserList'],
init: function() {
this.getUserStoreStore().load();
}
});
文件路徑:/app/store/UserStore.js
Ext.define('App.store.UserStore', {
extend: 'Ext.data.Store',
model: 'App.model.UserModel',
proxy: {
type: 'ajax',
url: 'app/data/contact.json'
}
});
文件路徑:/app/model/UserModel.js [模型]
Ext.define('App.model.UserModel',{
extends:'Ext.data.Model',
fields:[
{name: 'name', type: 'string'},
{name: 'age', type: 'string'},
{name: 'phone', type: 'string'},
{name: 'email', type: 'string'}
]
});
文件路徑:/app/view/UserList.js [查看]
Ext.define('App.view.user.UserList' ,{
extend: 'Ext.grid.Panel',
alias:'widget.userList',
title:'Contacts',
region:'center',
resizable:true,
initComponent: function() {
this.store = 'UserStore';
this.columns = [
{text: 'Name',flex:1,sortable: true,dataIndex: 'name'},
{text: 'Age',flex:1,sortable: true,dataIndex: 'age'},
{text: 'Phone',flex:1,sortable: true,dataIndex: 'phone'},
{text: 'Email',flex:1,sortable: true,dataIndex: 'email'}
];
this.callParent(arguments);
}
}) ;
在發生火災的錯誤它顯示了JSON迴應如下:
[{
"name": "Aswini",
"age": "32",
"phone": "555-555-5555",
"email": "[email protected]"
}]
爲什麼數據還未顯示出來,儘管我有一個有效的JSON響應。請幫忙!!!
哦笏這是我寫延伸,而不是在存儲擴展文件,它應擴展:'Ext.data.Model' – aswininayak 2012-03-29 13:21:05
您有有效的JSON響應,但是您有商店中的記錄嗎? – sha 2012-03-30 15:53:31
如果有,請分享解決方案嗎? – Patton 2012-04-05 09:17:07