Extjs如何用Grid显示Json数据?帮小弟我看下这个代码错在哪里
Extjs怎么用Grid显示Json数据?帮我看下这个代码错在哪里。
运行结果,表格显示出来了,但是没有加载任何数据。
------解决思路----------------------
store里有数据么?
Ext.onReady(function(){
var itemsPerPage = 2;//指定分页大小
var store = Ext.create('Ext.data.Store', {
autoLoad: {start: 0, limit: itemsPerPage},
fields:['id', 'title', 'detail'],
pageSize: itemsPerPage, //设置分页大小
proxy: {
type: 'ajax',
url: 'http://demo/Book/list.txt', //请求的服务器地址
reader: {
type: 'json',
root: 'rows',
totalProperty: 'results'
}
}
});
//创建Grid表格组件
Ext.create('Ext.grid.Panel',{
title : 'Ext.toolbar.Paging示例',
renderTo: Ext.getBody(),
width:400,
height:150,
frame:true,
store: store,
columns: [//配置表格列
{text: "类型编号", width: 80, dataIndex: 'id', sortable: true},
{text: "类型名称", width: 180, dataIndex: 'title', sortable: true},
{text: "类型说明", width: 280, dataIndex: 'detail', sortable: true}
],
bbar: [{
xtype: 'pagingtoolbar',
store: store, //这里需要指定与表格相同的store
displayInfo: true
}]
});
});
运行结果,表格显示出来了,但是没有加载任何数据。
------解决思路----------------------
store里有数据么?