Load list dynamically using ajax, or JsonP
Hi guys, I'm creating an app that load a list of hotels into a list from Mysql using a php file. so for that i have a model called hotel :
Code:
Ext.define('OdicyApp.model.Hotel', {
extend : 'Ext.data.Model',
config : {
fields : [
{ name : 'Nom', type : 'string' },
{ name : 'photo', type : 'string' },
{ name : 'etoile', type : 'int' },
{ name : 'ville', type : 'string' }
]
}
});
a Store that load the data using either ajax or JsonP (both dont work for me :S) :
Code:
Ext.define('OdicyApp.store.HotelsStore', {
extend : 'Ext.data.Store',
id : 'HotelsStore',
config : {
model : 'OdicyApp.model.Hotel',
autoload: true,
proxy : {
type : 'ajax',
url : './server/test.php',
reader : {
type : 'json',
rootProperty: 'hotels'
}
}
}
});
a view that containes the list :
Code:
Ext.define('OdicyApp.view.Hotels', {
extend : 'Ext.tab.Panel',
xtype : 'HotelsList',
id : 'HotelsView',
config : {
title : 'Liste des hotels',
iconCls: 'user',
items : [
{
xtype : 'list',
itemtpl :'<img class="photo" src="{photo_url}" width="100" height="100"/>\n\
<h2>{name}</h2>\n\
<div class="info">{address} <br/> {description} <br/><img src="{etoile_url}"/></div>',
title : 'Odicy Recommande',
store : 'HotelsStore',
height : 300
}
]
}
});
and the server side file .php returns valid json :
Code:
<?php
$server = "localhost";
$user = "root";
$password = "";
$bdd = "test";
mysql_connect($server, $user, $password);
mysql_select_db($bdd);
$query = "select * from etablissement";
$result = mysql_query($query) or die('nooo');
$return['hotels'] = '';
while ($line = mysql_fetch_array($result)){
$return['hotels'][] = array(
"name" => $line['nom'],
"photo_url" => $line['photo'],
"ville" => $line['ville'],
"etoile_url" => $line['etoile']
);
}
echo json_encode($return);
?>
Can any one tell me please what do I need to make it work .. by the way i get a warning in my console :
Quote:
Synchronously loading 'Ext.dataview.List'; consider adding 'Ext.dataview.List' explicitly as a require of the corresponding class