Bonjour,

Je suis actuellement dans un projet de WebDesktop avec le Framework ExtJs.

J'ai un problème avec une action sur le clique d'un bouton.

J'aimerais qu'au clique du bouton Ajouter, se trouvant dans la ToolBar de la fenêtre, un formulaire s'ouvre.

Malheureusement, Firebug met un message d'erreur : form is not Defined.

Code de la table
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
 
/*!
 * Ext JS Library 4.0
 * Copyright(c) 2006-2011 Sencha Inc.
 * licensing@sencha.com
 * http://www.sencha.com/license
 */
 
Ext.define('MyDesktop.Localite', {
    extend: 'Ext.ux.desktop.Module',
 
    requires: [
        'Ext.data.ArrayStore',
        'Ext.util.Format',
        'Ext.grid.Panel',
		'Ext.window.MessageBox',
		'Ext.tip.*',
        'Ext.grid.RowNumberer',
		'Ext.form.*',
		'Ext.layout.container.Column',
		'Ext.tab.Panel',
		'MyDesktop.FrmAjoutLocalite',
		'*'
    ],
 
    id:'tab_localite',
 
    init : function(){
        this.launcher = {
            text: 'Localites',
            iconCls:'icon-grid',
        };
    },
 
    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('tab_localite');
        if(!win){
            win = desktop.createWindow({
                id: 'tab_localite',
                title:'Localites',
                width:740,
                height:480,
                iconCls: 'icon-grid',
                animCollapse:false,
                constrainHeader:true,
                layout: 'fit',
                items: [
                    {
                        border: false,
                        xtype: 'grid',
                        store: new Ext.data.ArrayStore({
                            fields: [
                               { name: 'npaLocalite' },
                               { name: 'nomLocalite'}
                            ],
                            data: MyDesktop.Localite.getDummyData()
                        }),
                        columns: [
                            new Ext.grid.RowNumberer(),
                            {
                                text: "Numéro postal",
                                width: 150,
                                sortable: true,
                                dataIndex: 'npaLocalite'
                            },
                            {
                                text: "Nom",
                                width: 150,
                                sortable: true,
                                dataIndex: 'nomLocalite'
                            }
                        ]
                    }
                ],
                tbar:[{
                    text:'Ajouter',
                    tooltip:'Ajouter',
                    iconCls:'add',
					xtype: 'button',
					handler : function() {
						form.show();
					}	
				}, '-', {
                    text:'Modifier',
                    tooltip:'Modifier',
                    iconCls:'option',
					xtype: 'button'
                },'-',{
                    text:'Supprimer',
                    tooltip:'Supprimer',
                    iconCls:'remove',
					xtype: 'button'
                }]
            });
        }
        return win;
	},
    statics: {
        getDummyData: function () {
            return [
                ['2718','Lajoux'],
				['2873','Saulcy'],
				['2800','Delémont'],
				['2350','Saignelégier'],
				['2345','Les Breuleux'],
				['2720','Tramelan']				
            ];
        }
    },
 
 
});
Code du formulaire
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
Ext.define('MyDesktop.FrmAjoutLocalite', {
    extend: 'Ext.window.Window',
 
    height: 329,
    width: 496,
    title: 'Ajouter une localité',
 
	init : function(){
        this.launcher = {
            text: 'Ajouter une localité',
            iconCls:'icon-grid'
        };
    },
 
	createWindow : function(){
	var desktop = this.app.getDesktop();
        var form = desktop.getWindow('frmajoutlocal');
        if(!form){
				form = desktop.createWindow({
                id: 'frmajoutlocal',
                title:'Ajouter',
                width:740,
                height:480,
                iconCls: 'icon-grid',
                animCollapse:false,
                constrainHeader:true,
                layout: 'fit',
                items: [
					{
                    xtype: 'form',
                    height: 295,
                    bodyPadding: 10,
                    title: 'Ajouter une localité',
                    items: [
                        {
                            xtype: 'textfield',
                            width: 462,
                            fieldLabel: 'Code postal',
							name: 'npa_localite',
                            anchor: '100%'
                        },{
                            xtype: 'textfield',
                            width: 462,
                            fieldLabel: 'Localité',
							name: 'nom_localite',
                            anchor: '100%'
                        },
                    ]
                }
            ],
            });
		}
		return form;
	},
 
});
Merci d'avance !!!