2012-04-20 6 views
0

Architectを使用してSencha Touchで再生を開始しましたが、PHPを使用してJSONにMySQLデータベースからリストを挿入しようとしています。私はArchitectにスクリプト生成をさせましたが、実行時にデータを表示/表示するように見えます。私は何かが欠けていると確信しているので、いくつかの助けが大いに評価されるだろう。以下は、対応するコードスニペットです。Senchaを使用してJSONからリストビューを作成

添え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(); 
?> 

自動生成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}); 
    } 


}); 

生成されたモデル(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' 
      } 
     ] 
    } 
}); 

ストア(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' 
      } 
     } 
    } 
}); 

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 
. . . 

答えて

0

ないデータストアあなたの意見では、あなたは

... 
xtype: 'list' 
cls: ['list-Container'], 
store: MyApp.store.ACListStore 
itemTpl:'....' 
... 
の下に行うことができます
関連する問題