PDA

View Full Version : Nestedlist json



Beginner999
12 Feb 2013, 4:08 AM
Hello,

i want to use a sample of nestedlist for my own data.

the orginal sample:


{
xtype: 'nestedlist',
title: 'News',
iconCls: 'home',
displayField: 'title',


store: {
type: 'tree',


fields: [
'title',
{name: 'leaf', defaultValue: true}
],


root: {
leaf: false
},


proxy: {
type: 'jsonp',
url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
}
},


detailCard: {
xtype: 'panel',
scrollable: true,
styleHtmlContent: true
},


listeners: {
itemtap: function(nestedList, list, index, element, post) {
this.getDetailCard().setHtml(post.get('title'));
}
}
}


now i want to change this to my own page (for testing simply on localhost)



url: 'http://localhost/test.php',


Content of test.php is



<?
$aTest = array("responseData"=>array("feed"=>array("entries"=>array(array("title"=>"test")))));
echo json_encode($aTest);
?>



result:


{"responseData":{"feed":{"entries":[{"title":"test"}]}}}


but i get no list in sencha

bricemason
13 Feb 2013, 7:42 PM
The problem is that you have a jsonp proxy that isn't receiving jsonp from test.php. You could correct this two ways. First you could change the proxy type to use ajax:


proxy: {
type: 'ajax',
url: 'http://localhost/test.php',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
}

and it would work fine with your current test.php service. Alternatively you could keep the jsonp proxy but modify your test.php service to return jsonp:


<?
$aTest = array("responseData"=>array("feed"=>array("entries"=>array(array("title"=>"test")))));
echo $_GET['callback'] . '(' . json_encode($aTest) . ');';
?>



I hope this helps you.

Brice