controller
Ext.define('vts.controller.HomeController', {
extend: 'Ext.app.Controller',
views: ['Viewport', 'Main_Center', 'Main_Left'],
stores: ['Main_Left_GongGaoStore'],
model: ['Main_Left_GongGaoModel']
});
Main_Left视图
Ext.define('vts.view.Main_Left', {
extend: 'Ext.panel.Panel',
border: false,
alias: 'widget.Main_Left',
items: [{
region: 'south',
xtype: 'tabpanel',
height: 300,
activeTab: 0,
items: [{
title: '登陆信息',
html: ''
}, {
title: '系统信息',
html: ''
}]
}, {
title: '公告',
region: 'center',
layout: 'fit',
xtype: 'gridpanel',
store:'Main_Left_GongGaoStore',
columns: [
{ text: 'title', dataIndex: 'title' },
{ text: 'remark', dataIndex: 'remark'}
]
}]
});
MODEl
Ext.define('vts.model.Main_Left_GongGaoModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'title', type: 'varchar' },
{ name: 'remark', type: 'varchar' }
]
});
store
Ext.define("vts.store.Main_Left_GongGaoStore", {extend: 'Ext.data.Store',
requires: 'vts.model.Main_Left_GongGaoModel',
model: 'vts.model.Main_Left_GongGaoModel',
proxy: {
type: 'ajax',
url: '/VTS/Scripts/Json/Main_Left_GongGaoJson.json',
reader: 'json',
autoLoad: true
}
});
JSON文件
[{"title":"123","remark":"123"}]
页面显示正常,没有任何报错,但是表格控件就是没有数据显示,我用chrome浏览器监视到JSOn文件没有加载,但是我直接/VTS/Scripts/Json/Main_Left_GongGaoJson.json输入这个网址能正常显示JSON文件,求牛人解决下,本人是刚刚新学EXTJS的
store
Ext.define("vts.store.Main_Left_GongGaoStore", {extend: 'Ext.data.Store',
requires: 'vts.model.Main_Left_GongGaoModel',
model: 'vts.model.Main_Left_GongGaoModel',
proxy: {
type: 'ajax',
url: '/VTS/Scripts/Json/Main_Left_GongGaoJson.json',
reader: 'json'
},
autoLoad: true
});
autoLoad: true这个属性放错地方了
1.没有json文件,应该是请求的路径有些问题(调试或者看看network,如果路径问题,会发现请求文件404)
2.如果能进到后台,就调试后台的代码,这个不在你本次问题(因为你是直接请求的json文件)
总而言之,善用调试,尤其是写js的时候,一定要认真,js智能提示不给力