Oyentes en DataView en Sencha Touch 2
-
27-10-2019 - |
Pregunta
Tengo un problema con un Dataview
. los Dataview
Debería tener un oyente en los artículos que les convierte.
Así que así es como mi Dataview
parece:
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);
}
}
});
¿Alguien tiene alguna idea de por qué esto no funciona?
Editar: datos de plantilla agregados: var childrentRentEmplate = new Ext.xtemplate ('', '', '', '{nombre}', '', '', '', '{precio}', '', ',,',, ',, '', '');
Solución 2
Descubrí cuál era el problema.
DataView estaba en un contenedor que estaba en un tabpanel.
Después de alguna prueba y error, descubrí que si defino el contenedor como un objeto de configuración con Xtype: 'Container' funciona. Si creo el contenedor sobre ext.create ('ext.container', {}); De alguna manera no funciona. Ya se le preguntó en el foro Sencha si es un error o una función, lo mantendré actualizado.
Otros consejos
Pruebe el siguiente código; (para 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
});
Agregue el oyente con;
childrenData.on({
tap: function(data,index){
var record = data.getStore().getAt(index);
console.log(record);
}
});