PDA

View Full Version : Problem Controller for disclosure : how link itemdisclosure with controller for disp



gizmoone
20 Jul 2012, 1:57 PM
Hello,

It's ok for display in console.log when i use"onItemDisclosure: function() {console.log('text');}" after i put "onItemDisclosure: true" and i have the controller file.

But when i tap on itemdisclosure, i have nothing in console.log

app/controller/Fonction.js

Ext.define('proto.controller.Fonction', { extend: 'Ext.app.Controller',


config: {
refs: {
fonction: 'fonctioncard' // i try different syntax
},
control: {
'list': { // i try different syntax : fonctioncard, Fonction, ...
disclose: function() {console.log('disclose');}
}
}
}


});




app/view/Main.js

Ext.define('proto.view.Main', { extend: 'Ext.TabPanel',
requires: [
'proto.view.Fonction'
],


config: {
tabBar: {
docked: 'bottom',
layout: {
pack: 'center'
}
},
items: [
{ xtype: 'fonctioncard'
]
}
});

app/view/Fonction.js

Ext.define('proto.view.Fonction', { extend: 'Ext.navigation.View',
xtype: 'fonctioncard',
requires: [
'Ext.List',
'proto.store.FonctionCards',
'proto.controller.Fonction'
],


config: {
iconCls: 'more',
title: 'Fonction',
items: [{
title: 'Fonction',
xtype: 'list',
itemTpl: '{Name}',
store: 'FonctionCards',
onItemDisclosure: true


}]
}
});

app/model/Fonction.js

Ext.define('proto.model.Fonction', { extend: 'Ext.data.Model',


config: {
fields: [
{ name: 'Id', type: 'string' },
{ name: 'Name', type: 'string' },
{ name: 'Description', type: 'string' },
{ name: 'Visible', type: 'boolean' },
{ name: 'CreatedAt', type: 'date' },
{ name: 'UpdatedAt', type: 'date' },
{ name: 'DeletedAt', type: 'date' }
]
}
});

app/store/FonctionCards.js

Ext.define('proto.store.FonctionCards', {
extend: 'Ext.data.Store',
requires: [
'proto.model.Fonction'
],


config: {
autoLoad: true,
model: 'proto.model.Fonction',
storeId: 'FonctionCards',


// proxy fichier
proxy: {
type: 'ajax',
url: 'data/liste.json',

reader: {
type: 'json',
rootProperty: 'post'
}
}
}
});


app/data/liste.json

{"post":[ { Id: "1", Name:"id1", Description: "a", Visible: "O", CreatedAt: "", UpdatedAt: "", DeletedAt: "" }, { Id: "2", Name: "id4", Description: "a", Visible: "N", CreatedAt: "", UpdatedAt: "", DeletedAt: "" },
{ Id: "3", Name: "id3", Description: "a", Visible: "N", CreatedAt: "", UpdatedAt: "", DeletedAt: "" },
{ Id: "4", Name: "id4", Description: "a", Visible: "O", CreatedAt: "", UpdatedAt: "", DeletedAt: "" }]}

mitchellsimoens
22 Jul 2012, 9:24 AM
control : {
'list' : {
disclose : 'someFunc'
}
}

Should execute once you tap on the disclosure icon.