PDA

View Full Version : textfield missing



yannickiwi
28 Apr 2009, 12:22 AM
Hi,


I have 2 windows, which when I call, I lose textfield does not understand why. To be better understood, here is a picture:

http://img524.imageshack.us/img524/7033/empty.png

and the code:



var displayAddClient = new Ext.Window({
title: 'Ajouter un nouveau client',
id: 'addclient',
width: 500,
height: 500,
items: new Ext.form.FormPanel({
height: 500,
items:[{
xtype: 'textfield',
fieldLabel: 'Nom et Prénom*',
id: 'fullName',
name: 'fullName',
maxLength: 45,
allowBlank: false,
emptyText: 'Entrez un nom et un prénom',
anchor: '100%'
},{
xtype: 'textfield',
fieldLabel: 'Société',
id: 'society',
name: 'society',
maxLength: 45,
allowBlank: true,
emptyText: 'Entrez une société',
anchor: '100%'
},{
xtype: 'numberfield',
fieldLabel: 'NPA',
id: 'zip',
name: 'zip',
maxLength: 5,
allowBlank: true,
emptyText: 'Entrez un code postal',
anchor: '100%'
},{
xtype: 'textfield',
fieldLabel: 'Localité',
id: 'localite',
name: 'localite',
maxLength: 45,
allowBlank: true,
emptyText: 'Entrez une localité',
anchor: '100%'
},{
xtype: 'textfield',
fieldLabel: 'Ville',
id: 'city',
name: 'city',
maxLength: 60,
allowBlank: true,
emptyText: 'Entrez une ville',
anchor: '100%'
},{
xtype: 'textfield',
fieldLabel: 'Rte',
id: 'rte',
name: 'rte',
maxLength: 60,
allowBlank: true,
emptyText: 'Entrez une adresse',
anchor: '100%'
},{
xtype: 'numberfield',
fieldLabel: 'Tél. Prof.',
id: 'telprof',
name: 'telprof',
maxLength: 10,
allowBlank: true,
emptyText: 'Entrez un téléphone professionnel',
anchor: '100%'
},{
xtype: 'numberfield',
fieldLabel: 'Tél. Priv.',
id: 'telpriv',
name: 'telpriv',
maxLength: 10,
allowBlank: true,
emptyText: 'Entrez un téléphone privé',
anchor: '100%'
},{
xtype: 'textfield',
fieldLabel: 'E-Mail',
vtype: 'email',
id: 'email',
name: 'email',
maxLength: 45,
allowBlank: true,
emptyText: 'Entrez une adresse mail',
anchor: '100%'
}]
}),
buttons: [{
text: 'Sauvegarder',
handler: function(){
displayAddClient.items.items[0].getForm().submit({
url: '/set/client/updateClient/write/',
waitTitle:'Sauvegarde',
waitMsg:'Sauvegarde en cours...',
success: function(f,a){
clientStore.reload(); // reload method of a store, uses last load options
displayAddClient.hide(); // hide this windowForm
},
failure: function(f,a){
Ext.Msg.alert('Erreur','Echec de la sauvegarde du nouveau client.');
}
});
}
},{
text: 'Annuler',
handler: function(){
displayAddClient.hide();
}
}]
});

var displayAddProject = new Ext.Window({
title: 'Ajouter un nouveau projet',
id: 'addproject',
width: 500,
height: 500,
items: new Ext.form.FormPanel({
height: 500,
items:[{
xtype: 'textfield',
pageSize:10,
hideTrigger:true,
fieldLabel: 'Référence*',
id: 'ref',
name: 'ref',
maxLength: 45,
allowBlank: false,
emptyText:'Entrez une référence',
anchor: '100%'
},{
xtype: 'combo',
store: clientStore,
displayField:'fullName',
name: 'fullName',
fieldLabel: 'Client(e)*',
emptyText:'Sélectionner un(e) client(e)',
typeAhead: true,
triggerAction: 'all',
selectOnFocus:true,
allowBlank: false,
mode: 'remote',
anchor: '100%'
},{
xtype: 'textfield',
pageSize:10,
hideTrigger:true,
fieldLabel: 'Nom du projet*',
id: 'name',
name: 'name',
maxLength: 45,
allowBlank: false,
emptyText:'Entrez un nom pour ce projet',
anchor: '100%'
}]
}),
buttons: [{
text: 'Sauvegarder',
handler: function(){
displayAddProject.items.items[0].getForm().submit({
url: '/set/project/updateProject/write/',
waitTitle:'Sauvegarde',
waitMsg:'Sauvegarde en cours...',
success: function(f,a){
projectStore.reload(); // reload method of a store, uses last load options
displayAddProject.hide(); // hide this windowForm
},
failure: function(f,a){
Ext.Msg.alert('Erreur','Echec de la sauvegarde du nouveau projet.');
}
});
}
},{
text: 'Annuler',
handler: function(){
displayAddProject.hide();
}
}]
});



thanks for your help

yannick

shibubh
28 Apr 2009, 12:39 AM
first set the layout:'fit' to window.(i think the problem is not caught by this). and check use firebug to check the dom element of the form. check its exit there or not

yannickiwi
28 Apr 2009, 12:51 AM
0 error with firebug.


I do not know why, its working very well before and I myself was not more busy, the check I see his work.

yannickiwi
28 Apr 2009, 1:07 AM
I do not think the error comes from the same script, because I was copy / paste one that works in my other script. In other works, and its not here. Is what I can give you the complete code for analysis?

yannickiwi
28 Apr 2009, 11:07 PM
up

yannickiwi
29 Apr 2009, 2:19 AM
I have found the bug !

On my code:



var displayProjectPanel = new Ext.form.FormPanel({
....
{
xtype: 'textfield',
pageSize: 10,
hideTrigger: true,
fieldLabel: 'Référence*',
id: 'ref',
name: 'ref',
maxLength: 45,
allowBlank: false,
emptyText: 'Entrez une référence',
anchor: '100%'
},
...
});
...
var displayAddProject = new Ext.Window({
title: 'Ajouter un nouveau projet',
id: 'addproject',
width: 500,
height: 500,
layout: 'fit',
items: new Ext.form.FormPanel({
height: 500,
items: [{
xtype: 'textfield',
pageSize: 10,
hideTrigger: true,
fieldLabel: 'Référence*',
id: 'ref',
name: 'ref',
maxLength: 45,
allowBlank: false,
emptyText: 'Entrez une référence',
anchor: '100%'
},
{
xtype: 'combo',
store: clientStore,
tpl: '<tpl for="."><div class="x-combo-list-item">{fullName}, {zip}, {city}</div></tpl>',
displayField: 'fullName',
name: 'fullName',
fieldLabel: 'Client(e)*',
emptyText: 'Sélectionner un(e) client(e)',
typeAhead: true,
triggerAction: 'all',
selectOnFocus: true,
allowBlank: false,
mode: 'remote',
anchor: '100%',
listeners: {
select: function(f, r, i) {
if (i == 0) {
displayAddClient.show();
}
}
}
},
{
xtype: 'textfield',
pageSize: 10,
hideTrigger: true,
fieldLabel: 'Nom du projet*',
id: 'name',
name: 'name',
maxLength: 45,
allowBlank: false,
emptyText: 'Entrez un nom pour ce projet',
anchor: '100%'
}]
}),
buttons: [{
text: 'Sauvegarder',
handler: function() {
displayAddProject.items.items[0].getForm().submit({
url: '/set/project/updateProject/write/',
waitTitle: 'Sauvegarde',
waitMsg: 'Sauvegarde en cours...',
success: function(f, a) {
projectStore.reload(); // reload method of a store, uses last load options
displayAddProject.hide(); // hide this windowForm
},
failure: function(f, a) {
Ext.Msg.alert('Erreur', 'Echec de la sauvegarde du nouveau projet.');
}
});
}
},
{
text: 'Annuler',
handler: function() {
displayAddProject.hide();
}
}]
});


If I change the name and id on formPanel code, That's okay. but here, the name and id into formPanel code and the name and id into the window code is egual.

Can you help me?

If that's possible, I don't want to change this informations because is writed into my php code and I don't want double the php function.

yannickiwi
29 Apr 2009, 10:56 PM
up

yannickiwi
1 May 2009, 1:06 AM
up

Condor
1 May 2009, 2:19 AM
You can't have 2 components with the same id (component ids need to be unique!).

I suggest replacing id with itemId. You won't be able to use Ext.getCmp(id) anymore, but container.getComponent(itemId) will still work.

You can have multiple components with the same name, but it can cause problems on Internet Explorer because it has a buggy getElementById implementation.