gizmoone
26 Jul 2012, 12:51 AM
Hello
To finish my first application of training, I try understand the philosophy for the party blind.
I try to filter by the fields searchfield but not there arriving I already try by a simple function. That does not work not more.
An expert it can help me the objective being to do that correctly with the architecture MVC.
Thank you
app/view/FonctionList.js
Ext.define('proto.view.FonctionList', { extend: 'Ext.List',
xtype: 'fonctionlist',
requires: ['proto.store.Fonctions',
'Ext.field.Search',
'Ext.plugin.ListPaging',
'Ext.plugin.PullRefresh'],
config: {
title: 'Liste des fonctions',
grouped: true,
itemTpl: '{Name} {Id}',
store: 'Fonctions',
onItemDisclosure: true,
handler: function(){
var sto = Ext.getStore('Fonctions');
sto.clearFilter();
sto.filter('Name', 'AGENT');
},
items: [
{
xtype: 'toolbar',
docked: 'top',
items: [
{ xtype: 'spacer' },
{
xtype: 'searchfield',
placeHolder: 'Search...'
},
{ xtype: 'spacer' }
]
}
]
},
});
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' }
]
},
fullName: function() {
var d = this.data,
names = [
d.Name,
d.Id
];
return names.join(" ");
}
});
app/store/Fonctions.js
Ext.define('proto.store.Fonctions', { extend: 'Ext.data.Store',
config: {
model: 'proto.model.Fonction',
sorters: 'Name',
grouper : function(record) {
return record.get('Name')[0];
},
// proxy fichier
proxy: {
type: 'ajax',
url: 'data/liste.json',
reader: {
type: 'json',
rootProperty: 'post'
}
},
autoLoad: true,
}
});
app/controller/Fonction.js
Ext.define('proto.controller.Fonction', { extend: 'Ext.app.Controller',
config: {
refs: {
main: 'mainpanel'
},
control: {
'fonctionlist': {
disclose: 'showDetail'
}
}
},
showDetail: function(list, record) {
this.getMain().push({
xtype: 'fonctiondetail',
title: record.fullName(),
data: record.getData()
})
}
});
app/view/Fonction.js
Ext.define('proto.view.Fonction', { extend: 'Ext.navigation.View',
xtype: 'mainpanel',
requires: [
'proto.view.FonctionList',
'proto.view.FonctionDetail'
],
config: {
title: 'Fonctions',
iconCls: 'user',
items: [{
xtype: 'fonctionlist'
}]
}
});
To finish my first application of training, I try understand the philosophy for the party blind.
I try to filter by the fields searchfield but not there arriving I already try by a simple function. That does not work not more.
An expert it can help me the objective being to do that correctly with the architecture MVC.
Thank you
app/view/FonctionList.js
Ext.define('proto.view.FonctionList', { extend: 'Ext.List',
xtype: 'fonctionlist',
requires: ['proto.store.Fonctions',
'Ext.field.Search',
'Ext.plugin.ListPaging',
'Ext.plugin.PullRefresh'],
config: {
title: 'Liste des fonctions',
grouped: true,
itemTpl: '{Name} {Id}',
store: 'Fonctions',
onItemDisclosure: true,
handler: function(){
var sto = Ext.getStore('Fonctions');
sto.clearFilter();
sto.filter('Name', 'AGENT');
},
items: [
{
xtype: 'toolbar',
docked: 'top',
items: [
{ xtype: 'spacer' },
{
xtype: 'searchfield',
placeHolder: 'Search...'
},
{ xtype: 'spacer' }
]
}
]
},
});
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' }
]
},
fullName: function() {
var d = this.data,
names = [
d.Name,
d.Id
];
return names.join(" ");
}
});
app/store/Fonctions.js
Ext.define('proto.store.Fonctions', { extend: 'Ext.data.Store',
config: {
model: 'proto.model.Fonction',
sorters: 'Name',
grouper : function(record) {
return record.get('Name')[0];
},
// proxy fichier
proxy: {
type: 'ajax',
url: 'data/liste.json',
reader: {
type: 'json',
rootProperty: 'post'
}
},
autoLoad: true,
}
});
app/controller/Fonction.js
Ext.define('proto.controller.Fonction', { extend: 'Ext.app.Controller',
config: {
refs: {
main: 'mainpanel'
},
control: {
'fonctionlist': {
disclose: 'showDetail'
}
}
},
showDetail: function(list, record) {
this.getMain().push({
xtype: 'fonctiondetail',
title: record.fullName(),
data: record.getData()
})
}
});
app/view/Fonction.js
Ext.define('proto.view.Fonction', { extend: 'Ext.navigation.View',
xtype: 'mainpanel',
requires: [
'proto.view.FonctionList',
'proto.view.FonctionDetail'
],
config: {
title: 'Fonctions',
iconCls: 'user',
items: [{
xtype: 'fonctionlist'
}]
}
});