1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    10
    Vote Rating
    0
    y.elqandili1 is on a distinguished road

      0  

    Default Load list dynamically using ajax, or JsonP

    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 :
    Synchronously loading 'Ext.dataview.List'; consider adding 'Ext.dataview.List' explicitly as a require of the corresponding class

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,640
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    Moved to Ext Open Discussion to address this JavaScript question.

  3. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    20
    Vote Rating
    2
    jennifer123 is on a distinguished road

      0  

    Default


    Try changing rootProperty to root.

  4. #4
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,332
    Vote Rating
    83
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Are you using sencha touch 2.0 framework ? if, yes then rootProperty is ok.
    may be need to change your view try this view -
    Code:
    Ext.define('OdicyApp.view.HotelList', {
        extend : 'Ext.dataview.List',
        xtype  : 'HotelsList',
        id : 'HotelsView',
        title : 'Odicy Recommande',
        store:'HotelsStore',
        height:300,
        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>',
              });
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  5. #5
    Sencha User
    Join Date
    Jul 2012
    Posts
    10
    Vote Rating
    0
    y.elqandili1 is on a distinguished road

      0  

    Default


    thank you all guys .. but rootProprety works fine... i just had to change my view like sword-it said and changed my Json response to fit the properties in my Model & it worked .. Thanks for helping again ^^

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar