在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个回答

u010428741
小霸 这篇文章我看过,我找到原因了,我的root后面的值多打了个冒号
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!