salut,
je dev sur un projet en Extjs, je veux recupere des données d'un base oracle pour alimenter mon combo mais ça ne marche pas
ici mes code:
***************** le store et le template***************
*********************Le combo*******************
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 var ExploitationStore= new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: 'php/exploiation.php'}), reader: new Ext.data.JsonReader({ root: 'data',totalProperty: 'total', id: 'id'}, [ {name: 'ID', mapping: 'ID'}, {name: 'NOM', mapping: 'NOM'} ]) }); var ExploitationTemplate = new Ext.XTemplate( '<tpl for="."><div class="search-item">', '<span style="font-size:13px; font-weight:bold;"><span class="selectTitle">{ID}</span> - {NOM} </span>', '</div></tpl>'
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 xtype:'combo', fieldLabel: 'Exploitation', id:'comboExploitation', name:'comboExploitation', loadingText: 'Chargement en cours', pageSize:5, minChars:0, style:'width:90%', typeAhead: false, hideTrigger:false, itemSelector: 'div.search-item', store: ExploitationStore, tpl: ExploitationTemplate, onSelect: function(record){ this.setValue(record.data.ID + " " + record.data.NOM); this.collapse(); }==========> ce code fonctionne et retourne bien les données de format
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <?php //connexion à la base include ('C:\wamp\www\parc_auto/php/connexion.php'); // avoir la liste des exploitations $sql_exp = "SELECT exp_numero id, exp_libelle nom FROM exploitations" ; $stmt= oci_parse($ora_conn, $sql_exp); $list_exp = oci_execute($stmt); $tableau= array(); while ($objet = oci_fetch_object($stmt)) { $tableau[] = $objet; } $nb = oci_num_rows($stmt); echo '{"total":"'.$nb.'","data":'.json_encode($tableau).'}'; ?>
Merci de votre réponse
Code : Sélectionner tout - Visualiser dans une fenêtre à part {"total":"4","data":[{"ID":"TOUT","NOM":"TOUT"},{"ID":"1","NOM":"UN"},{"ID":"2","NOM":"DEUX"},{"ID":"3","NOM":"TROIS"}]}.
Partager