小霸 2016-10-26 03:05 采纳率: 0%
浏览 1112

在Ext 4.0中的MVC模式下,后台请求到了数据,在grid中不能显示,急!!!!

model层:
Ext.define('AM.model.CoModel',{
extend:'Ext.data.Model',
fields:[
{name:'seq',type:'string',mapping:'seq'},//序号,支持排序
{name:'name',type:'string',mapping:'name'},//企业名称
{name:'code',type:'string',mapping:'code'},//企业编码
{name:'riskLevel',type:'string',mapping:'riskLevel'},//风险级别
{name:'oType',type:'string',mapping:'oType'},//源区类型
{name:'cLevel',type:'string',mapping:'cLevel'},//经度
{name:'lat',type:'string',mapping:'lat'},//控制级别
{name:'gat',type:'string',mapping:'gat'}//维度
]
});
store:
Ext.define('AM.store.CoStore',{
extend:'Ext.data.Store',
model:'AM.model.CoModel',
proxy:{
type:'ajax',
url:'data/xxm/weektwo/JsonData.json',
reader:{
root:'rootData:',
type:'json',//json格式
totalProperty:'totalCount'
}
},
autoLoad: true
});
controller层:
Ext.define("AM.controller.TreeController",{
extend:'Ext.app.Controller',
init:function(){//初始化方法
this.control({
"gridList button[id=add]":{
click:function(button, e, eOpts){

Ext.Msg.alert("提示","121");
var str="";
console.log(str);
}

}
});
},
views:['Tree','GridList','TreeView'],
stores:['CoStore'],
models:['CoModel']
})
view层:
Ext.define("AM.view.GridList",{
extend:'Ext.grid.Panel',
alias:'widget.gridList',
store:'CoStore',
forceFit:true,
selModel:{
selType:'rowmodel'
},
multiSelect:true,
frame:true,
enableKeyNav:true,
colunmLines:true,
initComponent:function(){//初始化组件
this.callParent(arguments);//回调父类的构造函数
// var myStore = Ext.create('AM.store.CoStore');
// myStore.reload();
// this.store = myStore;
// Ext.Msg.alert("提示",myStore.getCount());
},
columns:[
{text:'序号',dataIndex:'seq'},//
{text:'企业名称',dataIndex:'name'},//
{text:'企业编号',dataIndex:'code'},
{text:'风险等级',dataIndex:'riskLevel'},
{text:'源区类型',dataIndex:'oType'},
{text:'控制级别',dataIndex:'cLevel'},
{text:'经度',dataIndex:'lat'},
{text:'维度',dataIndex:'gat'}
],
tbar:[//在顶部添加按钮,iconCls为图标
{xtype:'button',text:'添加',iconCls:'add',id:'add'},
{xtype:'button',text:'删除',iconCls:'delete',id:'delete'},
{xtype:'button',text:'修改',iconCls:'edit',id:'edit'},
{xtype:'button',text:'查询',iconCls:'search',id:'search'}
],
dockedItems:[//也是定义插件的一种,以下为添加分页dock定位
{ //显示分页信息
xtype:'pagingtoolbar',//分页插件别名
store:'CoStore',//数据源
dock:'bottom',//定位
displayInfo:true
}
]
})
Ext.define("AM.view.Tree",{
extend:'Ext.tree.Panel',
alias:'widget.TrView',
rootVisible:false,
animate:false,
root:{
text:'root',
leaf:false,
id:'0',
children:[
{
text:'企业管理',
leaf:false,
checked:false,
id:'01',
children:[
{text:'企业信息',id:'02',leaf:true,checked:false}
]
}
]
}
});
Ext.define("AM.view.TreeView",{
extend:'Ext.panel.Panel',
title:'企业管理',
alias:'widget.treeView',
defaults:{
split:true,
bodyStyle:'padding:1px'
},
layout:'border',
items:[
{
title:'企业信息',
region:'west',
xtype:'panel',
margins:'5 2 5 5',
width:200,
collapsible:true,//可折叠
layout:'fit',
items:[
{

xtype:'TrView'
}
]
},{
title:'企业表',
region:'center',
xtype:'panel',
margins:'5 5 5 0',
collapsible:true,//可折叠
layout:'fit',
items:[
{
xtype:'gridList'
}
]
}
]
})
app:
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.Loader.setConfig({//启用Loader
enabled:true
})
Ext.application({
name:'AM',//应用的名字,加载的时候会先从设置AM的文件目录下,一层一层的往下找
appFolder:'js/xxm/weekone/app',//加载的目录
launch:function(){//当前页面加载完成执行的函数
Ext.create("Ext.container.Viewport",{
//layout:'auto',//自动布局
items:[
{
xtype:'treeView',
width:900,
height:500
}
]
})
},
controllers:[
'TreeController'
]
})
})
后台json数据(经格式验证没错):
{"totalCount":10,"rootData":
[{"seq":"1","name":"生益科技有限公司","code":"3241321232","riskLevel":"敏感区","oType":"安顺片区","cLevel":"市控","lat":"154.1323","gat":"32.2323"},
{"seq":"2","name":"春桥科技有限公司","code":"1241242234","riskLevel":"非重大污染","oType":"贵阳片区","cLevel":"国控","lat":"134.1323","gat":"22.2323"},
{"seq":"3","name":"新达共创科技有限公司","code":"2341321252","riskLevel":"敏感区","oType":"安顺片区","cLevel":"省控","lat":"144.1323","gat":"42.2323"},
{"seq":"4","name":"锐步科技责任公司","code":"1241651237","riskLevel":"敏感区","oType":"贵阳片区","cLevel":"省控","lat":"174.1323","gat":"45.2323"},
{"seq":"5","name":"近利科技有限公司","code":"2241321232","riskLevel":"非重大污染","oType":"贵阳片区","cLevel":"国控","lat":"164.1323","gat":"32.2323"},
{"seq":"6","name":"华盖科技有限公司","code":"9241321232","riskLevel":"重大污染","oType":"安顺片区","cLevel":"省控","lat":"154.1323","gat":"23.2323"},
{"seq":"7","name":"卓普科技有限公司","code":"7241321232","riskLevel":"敏感区","oType":"贵阳片区","cLevel":"市控","lat":"124.1323","gat":"32.2323"},
{"seq":"8","name":"崇胜科技有限公司","code":"8241321232","riskLevel":"非重大污染","oType":"安顺片区","cLevel":"省控","lat":"154.1323","gat":"32.2323"},
{"seq":"9","name":"起名科技有限公司","code":"6241321232","riskLevel":"敏感区","oType":"安顺片区","cLevel":"省控","lat":"134.1323","gat":"26.2323"},
{"seq":"10","name":"朗鑫智能科技有限公司","code":"5241321232","riskLevel":"重大污染","oType":"贵阳片区","cLevel":"国控","lat":"154.1323","gat":"37.2323"}
]
}

  • 写回答

1条回答

  • zqbnqsdsmd 2016-10-27 16:52
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号