Extjs3.2,GridPanel无法加载后台传来的json字符串

joyce_liu0216 2013-06-26 12:04:17
初学ExtJS,后台传回来的json始终无法显示到grid上,望高手帮助~~
html部分:

<div id="hello"></div>
<div id="element"></div>

js部分:

Ext.onReady(function () {
var store = new Ext.data.JsonStore({
url: "http://localhost/getData.ashx?method=try&random=0.9640254709105345",
autoload:true,
root: "results",
fields:["id","name","sex","email",name:"bornDate",type:"date",dateFormat:"Y-n-j"}]
});
document.getElementById("element").innerHTML = "<select id='sexList'><option>男</option><option>女</option></select>";
var colM = new Ext.grid.ColumnModel([{
header: "姓名",
dataIndex: "name",
sortable: true,
editor: new Ext.form.TextField()
},
{ header: "性别",
dataIndex: "sex",
editor: new Ext.form.ComboBox({ transform: "sexList", //select元素id
triggerAction: 'all',
lazyRender: true
})
},
{ header: "出生日期",
dataIndex: "bornDate",
width: 120,
renderer: Ext.util.Format.dateRenderer('Y年m月d日'),
editor: new Ext.form.DateField({ format: 'Y年m月d日' })
},
{ header: "电子邮件",
dataIndex: "email",
sortable: true,
editor: new Ext.form.TextField()
}
]);
var grid = new Ext.grid.EditorGridPanel({
renderTo: "hello",
title: "学生基本信息管理",
height: 200,
width: 600,
cm: colM,
store: store,
autoExpandColumn: 3,
clicksToEdit: 1
});

});

其中,url中http://localhost/getData.ashx?method=try&random=0.9640254709105345返回的内容为:

{results:[{id:1,name:'小王',email:'xiaowang@easyjf.com',sex:'男',bornDate:'1991-4-4'},{id:1,name:'小李',email:'xiaoli@easyjf.com',sex:'男',bornDate:'1992-5-6'},{id:1,name:'小兰',email:'xiaoxiao@easyjf.com',sex:'女',bornDate:'1993-3-7'}] }
...全文
66 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧