私のコードにはエラーが表示されていません。私のphpファイルも応答しています(firebugが報告しています)。しかし、グリッドにはデータが表示されていません。http://dev.sencha.com/deploy/ext-3.4.0/examples/feed-viewer/view.htmlから助けを得ようとしましたが、理解できませんでした!. アイデアは、プログラムにRSSフィードURLを提供することであり、そのURLからデータを取得する必要があり、次にphpファイルがExtJSの例(上記のリンクから)と同じように適切なxml形式に配置する必要があります。この時点まで、プログラムは正常に動作しています、firebugは応答がxmlであると言っていますが、現在はロードされていません。コード:
var remoteProxy = new Ext.data.HttpProxy({
url : 'feed-proxy.php'
});
var store = new Ext.data.Store({
proxy : remoteProxy,
id : 'ourRemoteStore',
reader : new Ext.data.XmlReader({
record : 'item'
}, [{
name : 'title',
mapping : 'title'
}])
});
loadFeed = function(url) {
store.baseParams = {
feed : url
};
store.load();
console.log(store.getCount());
}
loadFeed('http://sports.yahoo.com/nba/rss.xml');
var mWIn = new Ext.Window({
title : 'My Window',
width : 500,
height : 400,
layout : 'fit',
items : [{
xtype : 'grid',
store : store,
id : 'myGrid',
loadMask : true,
columns : [{
id : 'title',
header : "Title",
dataIndex :'title',
sortable : true,
width : 420
}]
}]
}).show();
Ext.getCmp('myGrid').ownerCt.doLayout();
およびphpファイルコードは次のとおりです。
<?php
// this is an example server-side proxy to load feeds
if(isset($_REQUEST['feed'])){
$feed = $_REQUEST['feed'];
if($feed != '' && strpos($feed, 'http') === 0){
header('Content-Type: text/xml');
$xml = file_get_contents($feed);
$xml = str_replace('<content:encoded>', '<content>', $xml);
$xml = str_replace('</content:encoded>', '</content>', $xml);
$xml = str_replace('</dc:creator>', '</author>', $xml);
echo str_replace('<dc:creator', '<author', $xml);
return;
}
}
?>