JsonStore无法读取json文件的问题
nsyqseky
2008-11-13
使用jsonstore与服务器交互,读到的store的长度老是0,尝试用静态JSON,还是没用
test.html 写道
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="lib/ext/resources/css/ext-all.css" /> <script type="text/javascript" src="lib/ext/adapter/ext/ext-base.js"> </script> <script type="text/javascript" src="lib/ext/ext-all.js"> </script> <script type="text/javascript" src="lib/ext/ext-all-debug.js"> </script> <script> try { Ext.onReady(function(){ function showUrl(value){ return "<a href='" + value + "' >" + value + "</a>"; } var store = new Ext.data.JsonStore({ url:"data.json", root:"result", fields: ["id", "name", "organization", "homepage"] }); alert(store.getCount()); var colM = new Ext.grid.ColumnModel([{ header: "项目名称", dataIndex: "name", sortable: true }, { header: "开发团队", dataIndex: "organization", sortable: true }, { header: "网址", dataIndex: "homepage", renderer: showUrl }]); var grid = new Ext.grid.GridPanel({ renderTo: "hello", title: "asfsad", height: 200, width: 600, cm: colM, store: store, autoExpandColumn: 1 }); }); } catch (e) { Ext.log(e.message); } </script> </head> <body> <div id="hello"> </div> </body> </html> data.json 写道
{
result: [{ id: 1, name: 'EasyJWeb', organization: 'EasyJF', homepage: 'www.easyjf.com' }, { id: 2, name: 'jfox', organization: 'huihoo', homepage: 'www.huihoo.org' }, { id: 3, name: 'jdon', organization: 'jdon', homepage: 'www.jdon.com' }, { id: 4, name: 'springside', organization: 'springside', homepage: 'www.springside.org.cn' }] } |
|
nsyqseky
2008-11-13
![]() |
|
suncf1985
2008-11-17
![]() |