私の見解 ProvaincePanel.js
Ext.define('MyApp.view.ProvaincePanel', {
extend: 'Ext.dataview.NestedList',
alias : 'widget.provaincePanel',
config: {
store : 'Provainces',
title: 'Select your Provaince',
displayField: 'text',
detailCard: {
html: 'You can see detail information here!'
}
}
});
私の店 Provainces.js
Ext.define('MyApp.store.Provainces', {
extend: 'Ext.data.TreeStore',
config: {
model: 'MyApp.model.Provaince',
proxy: {
type: 'ajax',
url: 'http://127.0.0.1/pbesse-test/list-provainces3.php',
}
}
});
私のモデルProvaince.js
Ext.define('MyApp.model.Provaince', {
extend: 'Ext.data.Model',
config: {
fields: [{
name: 'text',
type: 'string'
}]
}
});
私のコントローラーTheWorld.js
Ext.define('MyApp.controller.TheWorld', {
extend : 'Ext.app.Controller',
config: {
profile: Ext.os.deviceType.toLowerCase(),
stores : ['Provainces'],
models : ['Provaince'],
refs: {
myContainer: 'provaincePanel'
},
control: {
'provaincePanel': {
activate: 'onActivate',
leafitemtap: 'onDetailDisplay'
}
}
},
onActivate: function() {
console.log('Main container is active');
},
onDetailDisplay: function(nestedList, list, index, target, record) {
var detailCard = nestedList.getDetailCard();
detailCard.setHtml('Here is the detail information for ' +
record.get('text'));
},
onItemTap: function(view, list, index, target, record, event) {
console.log('Item was tapped on the Data View');
console.log(view, list, index, target, record, event);
if(event.target.type == "button"){
Ext.Msg.alert('You clicked on the Button ...',
'The country code selected is: ' + event.target.name);
}
else {
Ext.Msg.alert('You clicked on the Row ...',
'The country code selected is: ' + record.get('code'));
}
//return false;
},
init: function() {
console.log('Controller initialized');
},
});
list-provainces3.php ファイルには含まれています
<?php
@mysql_connect('127.0.0.1','root','') or die(mysql_error());
@mysql_select_db('pbesse_test');
$node = $_GET['node'];
$node = explode('%2F', $node);
if(count($node) == 1)
{
$sql = "SELECT * FROM provainces";
$req = mysql_query($sql) or die(mysql_error());
$data = array();
while($res = mysql_fetch_array($req)){
$tmp = array();
$tmp['id'] = "root/".$res['id'];
$tmp['text'] = utf8_encode($res['libelle']);
$tmp['leaf'] = false;
$tmp['cls'] = 'folder';
$data[] = $tmp;
}
}
if(count($node) == 2){
$sql = "SELECT * FROM chateaux where id_provaince = ". $node[1];
$req = mysql_query($sql) or die(mysql_error());
$data = array();
while($res = mysql_fetch_array($req)){
$tmp = array();
$tmp['id'] = "root/".$res['id_provaince']."/".$res['title'];
$tmp['text'] = utf8_encode($res['libelle']);
$tmp['leaf'] = false;
$tmp['cls'] = 'folder';
$data[] = $tmp;
}
}
header('Content-Type: application/json, charset=UTF-8');
echo str_replace('\\','' , json_encode($data));
exit;
?>
アプリケーションを実行すると、国のリストが表示されますが、国名をクリックすると、ロード中のメッセージとアプリケーションのバグが表示されます