我正在尝试从 imdb 加载数据,但我在表 (GridPanel) 中没有结果。这是我的源代码:
...
<body>
<script type="text/javascript">
Ext.onReady(function(){
var store1 = new Ext.data.JsonStore({
root: 'root',
idProperty: 'ID',
remoteSort: true,
fields: [
'Title'
],
// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
proxy: new Ext.data.ScriptTagProxy({
url: 'http://www.imdbapi.com/?t=True%20Grit'
})
});
// building grid panel
});
</script>
<div id="topic-grid"></div>
...
也许我应该更改 JsonStore 中的“root”参数?
更新
我尝试使用 HttpProxy,但仍然没有结果。我把我所有的身体内容都放了也许会更有帮助。
<script type="text/javascript">
Ext.onReady(function(){
var store1 = new Ext.data.JsonStore({
reader: new Ext.data.JsonReader({
fields: ['Title'],
root: 'rows'
}),
// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
proxy: new Ext.data.HttpProxy({
url: 'http://www.imdbapi.com/?t=True%20Grit'
}),
autoLoad: true
});
var grid1 = new Ext.grid.GridPanel({
width:700,
height:500,
title:'ExtJS.com - Browse Forums',
store: store1,
trackMouseOver:false,
disableSelection:true,
loadMask: true,
// grid columns
columns:[{
id: 'Title',
header: "Topic",
dataIndex: 'Title',
width: 420,
sortable: true
}]
});
// render it
grid1.render('topic-grid');
// trigger the data store load
store1.load({params:{start:0, limit:25}});
});
</script>
<div id="topic-grid"></div>