日期:2014-05-17  浏览次数:20808 次

extJs4 grid不显示数据,新手求救
表结构可以显示的,但数据不显示
Ext.define('Tie',{
extend:'Ext.data.Model',
fields:[{name:'id',type:'int',mapping:'id'},
        {name:'title',type:'string',mapping:'title'},
        {name:'content',type:'string',mapping:'content'},
        {name:'parentId',type:'int',mapping:'parentId'}
       ]
});
Ext.create('Ext.data.Store',{
storeId:'s_tie',
model:'Tie',
proxy:{
type:'ajax',
url:'/extjs/list.do',
reader:{
type:'json',
root:'topics'
},writer:{
type:'json'
}
},
autoLoad:true
});

页面
<script type="text/javascript" src="ext/ext-all.js" ></script>
<script type="text/javascript" src="ext/model.js" ></script>
<script type="text/javascript" src="ext/ext-lang-zh_CN.js" ></script>
<script type="text/javascript" src="ext/bootstrap.js" ></script>
 <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" />
 <script type="text/javascript">
 Ext.require(['Ext.grid.*','Ext.toolbar.Paging','Ext.data.*']);
Ext.onReady(function(){
Ext.QuickTips.init();
var gr=Ext.create('Ext.grid.Panel',{
title:'列表',
columns:[{header:"编号",dataIndex:'id'},
         {header:"标题",dataIndex:'title'},
         {header:"内容",dataIndex:'content'},
         {header:"父编号",dataIndex:'parentId'}],
renderTo:'grid',
store:Ext.data.StoreManager.lookup('s_tie'),
height:200,
width:400
})
});
</script>
<title>Insert title here</title>
</head>
<body>
<div id="grid"></div>
</body>

action是可以进去的,返回的Json数组是{"totals":"5","topics":[{"content":"12","id":1,"parentId":0,"title":"12"},{"content":"1234","id":4,"parentId":1,"title":"1234"},{"content":"阿什顿","id":5,"parentId":4,"title":"咪好"}]}

------解决方案--------------------
<script type="text/javascript" src="${webRoot}/scripts/ext/adapter/ext/ext-base.js"></script>
有没有引入这个?
------解决方案--------------------
没看出有什么问题啊
------解决方案--------------------
是results rows不是totals topics
------解决方案--------------------
ext-base.js不是和你说了吗?引入这个,不引入会出现这样的问题,怎么不试试?
------解决方案--------------------