0

I just started playing with Sencha Touch using Architect and I'm trying to populate a list from a MySQL database using PHP to JSON. I let Architect do the script generation but I cant seem to get it to populate/show the data at run time. I am sure I'm missing something so some help would be greatly appreciated. Below are the suporting code snippets.

The Served PHP:

<?php//MySQL Database Connect
include 'andaerologin.php';


mysql_select_db("andaero");
$sql = mysql_query("select * from regulatory_list");


$output = array();
/* used "key" as name */
$output['listTitle'] = 'Regulatory_Guidance_Library';
$output['targetKey'] = 'bodyContent';


while ($row = mysql_fetch_assoc($sql)) {
    $output['items'][] = $row;
}


header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
echo(json_encode($output));


mysql_close();
?>

Auto Generated app.js:

Ext.Loader.setConfig({
    enabled: true
});


Ext.application({
    models: [
        'ListDefaultModel'
    ],
    stores: [
        'ACListStore'
    ],
    views: [
        'ViewPort'
    ],
    name: 'MyApp',


    launch: function() {


        Ext.create('MyApp.view.ViewPort', {fullscreen: true});
    }


});

Generated Model (ListDefaultModel.js):

Ext.define('MyApp.model.ListDefaultModel', {
    extend: 'Ext.data.Model',
    config: {
        idProperty: 'listDefaultModel',
        fields: [
            {
                allowNull: false,
                name: 'label',
                type: 'string'
            },
            {
                name: 'title',
                type: 'string'
            },
            {
                name: 'discription',
                type: 'string'
            }
        ]
    }
});

The Store (ACListStore):

Ext.define('MyApp.store.ACListStore', {
    extend: 'Ext.data.Store',
    requires: [
        'MyApp.model.ListDefaultModel'
    ],


    config: {
        model: 'MyApp.model.ListDefaultModel',
        storeId: 'ACListStore',
        proxy: {
            type: 'ajax',
            url: 'http://192.168.1.34/andaero/php/regulatory_list.php',
            reader: {
                type: 'json',
                rootProperty: 'items'
            }
        }
    }
});

The list container within the ViewPort.js:

. . .
xtype: 'list',
cls: [
      'list-Container'
       ],
        itemTpl: [
                '<div>',
                 '<h1>label {script}</h1>',
                 '<h2>title {script}</h2>',
                 '<p>description {script}</p>',
                 '<hr/>',
                 '</div>'
         ],
          scrollToTopOnRefresh: false,
          grouped: true
. . .
sha
  • 17,824
  • 5
  • 63
  • 98

1 Answers1

0

not data stores in your views, you can do below

... 
xtype: 'list'
cls: ['list-Container'],
store: MyApp.store.ACListStore
itemTpl:'....'
...
Scott.N
  • 172
  • 2
  • 17