首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

新手照着例子写的extjs的GridPanel出现的有关问题

2012-05-20 
新手照着例子写的extjs的GridPanel出现的问题JScript codeExt.onReady(function(){var cm new Ext.grid.

新手照着例子写的extjs的GridPanel出现的问题

JScript code
Ext.onReady(function(){                    var cm = new Ext.grid.ColumnModel([                        {header:"姓名",width:80,dataIndex:"Name",tooltip:"您的姓名"},                        {header:"性别",width:40,dataIndex:"Sex",align:"center"},                        {header:"生日",width:150,dataIndex:"Birthday",format:"Y-m-d"},                        {header:"学历",width:80,dataIndex:"Education",align:"center"},                        {id:"memo",header:"备注",dataIndex:"Memo"}                    ]);                    var data = [                        {name:"jay",sex:"男",brithday:Date.parseDate("1979-04-11","Y-m-d"),edu:"本科",memo:"无备注"},                        {name:"join",sex:"女",brithday:Date.parseDate("1981-02-13","Y-m-d"),edu:"本科",memo:"菜"},                        {name: "ajax",sex: "女",birthday: Date.parseDate("1980-05-12","Y-m-d"),edu: "本科",memo: "无备注"},                        {name: "flex",sex: "男",birthday: Date.parseDate("1980-12-11","Y-m-d"),edu: "本科",memo: "呵呵"}                    ];                var proxy = new Ext.data.MemoryProxy(data);                                var Human = Ext.data.Record.create(                    {name:"Name",type:"string",mapping:"name"},                    {name:"Sex",type:"string",mapping:"sex"},                    {name:"Birthday",type:"string",mapping:"bitthday"},                    {name:"Education",type:"string",mapping:"edu"},                    {name: "Memo", type: "string", mapping: "memo"}                );                                var reader = new Ext.data.JsonReader({},Human);                                var store = new Ext.data.Store({                    proxy:proxy,                    reader:reader                });                    store.load();                                var grid = new Ext.grid.GridPanel(                    {                        title:"Grid",                        width:600,                        autoHeight:true,                        cm:cm,                        store:store,                        renderTo:Ext.getBody(),                        autoExpandColumn:"memo"                    }                );                                                                                });

照着例子写的,但是数据源出不来,只是一个空的表格,求高手指教那出错了,在线等。


[解决办法]
extjs引入路径正确吗?

firebug下看看 报什么错。
[解决办法]
Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}


}
});

Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
这是帮助文档上的例子

热点排行