ascoltatori nel DataView in Sencha Touch 2
-
27-10-2019 - |
Domanda
Ho un problema con un Dataview
. Il Dataview
dovrebbe avere un ascoltatori sulle voci rende.
: ecco come il mio aspetto Dataview
come:
var childrenData = Ext.create('Ext.DataView', {
store: {
fields: ['id', 'name', 'children'],
proxy: {
type: 'ajax',
url: '/category/view',
reader: {
type: 'json',
}
},
autoLoad: true,
},
itemTpl: childrenTemplate,
listeners: {
itemtap: function(data,index){
var record = data.getStore().getAt(index);
console.log(record);
}
}
});
Qualcuno ha, qualche idea del perché questo non funziona?
Edit: aggiunte dati Template: var childrenTemplate = new Ext.XTemplate ( '', '', '', '{nome}', '', '', '', '{Prezzo}', '', '', '', '' );
Soluzione 2
ho scoperto quale fosse il problema.
Il dataview era in un contenitore che si trovava in una TabPanel.
Dopo alcuni tentativi ed errori, ho scoperto che se io definisco il contenitore come un oggetto di configurazione con xtype: 'contenitore' Funziona. Se creo il contenitore sopra Ext.create ( 'Ext.Container', {}); in qualche modo non funziona. Già ha chiesto nel Forum Sencha se un bug o una funzione, vi terrò aggiornati.
Altri suggerimenti
Si prega di provare sotto il codice; (Per sencha-touch-2)
var childrenData = Ext.create('Ext.DataView', {
store: {
fields: ['id', 'name', 'children'],
proxy: {
type: 'ajax',
url: '/category/view',
reader: {
type: 'json',
}
},
autoLoad: true,
},
itemTpl: childrenTemplate
});
add ascoltatore con;
childrenData.on({
tap: function(data,index){
var record = data.getStore().getAt(index);
console.log(record);
}
});