ExtJS、FormPanel 和 TabPanel 组件:post 未发送所有字段

发布于 2024-10-30 13:50:46 字数 7867 浏览 0 评论 0原文

这是我的问题:只要不显示选项卡,选项卡中包含的数据就不会发送。如果我单击一个选项卡,数据就会添加到“堆栈”中,并通过 post 事件发送。 (见代码) 我不明白的是我正在使用“deferredRender:false”。这似乎是唯一可以用来“强制”场计算的东西。我不知道我错过了什么,但我错过了一些东西。 谁能帮助我吗?

多谢。

这是 DossierPanel 类的完整源代码(有效):

DossierPanel = Ext.extend(Ext.form.FormPanel, {
    closable: true,
    autoScroll:true,

    initComponent : function(){
        var n = this.id_dossier;
        if (this.nom) {
            n += ' '+this.nom
        }
        if (this.prenom) {
            n += ' '+this.prenom;
        }
        this.title = n;
        this.id = 'id_dossier_'+this.id_dossier;
        this.bodyStyle = 'padding:15px';
        this.labelWidth = 150;
        this.items = [{
            layout:'column',
            border:false,
            autoHeight: true,
            items:[{
                columnWidth:.5,
                layout: 'form',
                border:false,
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'Civilite ',
                    name: 'CIVILITE',
                    readOnly: true
                }, {
                    xtype:'textfield',
                    fieldLabel: 'Nom ',
                    name: 'NOM',
                    anchor:'95%'
                }, {
                    xtype:'textfield',
                    fieldLabel: 'Prenom ',
                    name: 'PRENOM',
                    anchor:'95%'
                }]
            },{

                columnWidth:.5,
                layout: 'form',
                border:false,
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'RaisonSociale ',
                    name: 'RAISONSOCIALE',
                    anchor:'95%'
                },{
                    xtype:'textfield',
                    fieldLabel: 'Email ',
                    name: 'EMAIL',
                    vtype:'email',
                    anchor:'95%'
                }]
            }]
        },{
            xtype:'tabpanel',
            plain:true,
            activeTab: 0,
            /* (!) For a tab to force calculation, I use
             * deferredRender: false
             * It's very important for Form with multiple Tabs
             */
            deferredRender: false,
            defaults:{bodyStyle:'padding:10px'},
            items:[{
                title:'Détails personnels',
                layout:'form',
                autoHeight: true,
                defaults: {width: '99%'},
                defaultType: 'textfield',

                items: [{
                    fieldLabel: 'Poids ',
                    name: 'POIDS',
                    readOnly: true
                }, {
                    xtype:'datefield',
                    fieldLabel: 'Date premier contact ',
                    name: 'DATE1ERCONTACTJMA',
                    readOnly: true,
                    format:'d/m/Y'
                }, {
                    xtype:'datefield',
                    fieldLabel: 'Date étude dossier ',
                    name: 'DATEDATE_ETUDE_DOSSIERJMA',
                    format:'d/m/Y'
                }]
            },{
                title:'Adresse',
                layout:'form',
                autoHeight: true,
                defaults: {width: '95%'},
                defaultType: 'textfield',
                items: [{
                    fieldLabel: 'Adresse 1 ',
                    name: 'ADRESSE1'
                }, {
                    fieldLabel: 'Pays ',
                    name: 'PAYS',
                    readOnly: true
                }]
            },{
                title:'Téléphone(s)',
                layout:'form',
                autoHeight: true,
                defaults: {width: 230},
                defaultType: 'textfield',
                items: [{
                    fieldLabel: 'NoTelephone2 ',
                    name: 'NOTELEPHONE2',
                }, {
                    fieldLabel: 'DescTelephone3 ',
                    name: 'DESCTELEPHONE3',
                    readOnly: true
                }, {
                    fieldLabel: 'NoTelephone3 ',
                    name: 'NOTELEPHONE3',
                }]
            },{
                title:'Divers',
                layout:'form',
                autoHeight: true,
                defaults: {width: 230},
                defaultType: 'textfield',
                items: [{
                    fieldLabel: 'Mot de passe Internet ',
                    name: 'MOTDEPASSE'
                }, {
                    fieldLabel: 'Parts ',
                    name: 'PARTS'
                }, {
                    fieldLabel: 'Commission ',
                    name: 'COMMISSION'
                }]
            },{
                id: 'tab_emprunts_'+this.id_dossier,
                title:'Emprunts',
                layout:'form',
                autoHeight: true,

                defaults: {width: '99%'},
                defaultType: 'textfield',
                items: []
            }]
        }];
        this.buttonAlign = 'left';
        this.buttons = [{
            text: 'Recharger',
            handler: function() {
                this.getForm().load( {
                  url: '/ws/cellulemedicale/jsonEditDossier.php',
                  params: {
                      id_dossier: this.id_dossier
                  },
                  waitTitle: 'Wait',
                  waitMsg: 'Refresh',
                  failure:function(form, action) {
                        globGestionErreurAjax(action.response,'Refresh error');
                  }
                });
            },
            scope: this
        },{
            text: 'Sauver',
            handler: function() {
                this.getForm().submit({
                    url: '/ws/cellulemedicale/jsonEditDossier.php',
                    params: {
                        write: 1,
                        id: this.id_dossier
                    },
                    waitTitle: 'Wait...',
                    waitMsg: 'Saving',
                    success: function (form, action) {
                      var b = Ext.util.JSON.decode(action.response.responseText);
                      if (b.success==true) {
                          if (b.msg) {
                              Ext.MessageBox.alert('Done!', b.msg);
                          }
                          else {
                              Ext.MessageBox.alert('Done!', 'Saved ok');
                          }
                      }
                    },
                    failure:function(form, action) {
                        globGestionErreurAjax(action.response,'Save error');
                    }
                });
            },
            scope: this
        }];
        this.on('actioncomplete', function (form,action) {
            if (action.type=='load') {
                console.log(action.result.data.emprunts);
                if(typeof action.result != 'undefined') {
                    if(typeof action.result.data != 'undefined') {
                        if(typeof action.result.data.emprunts != 'undefined') {
                            /* For now, use the id, this may be ugly:
                             */
                            var tab = Ext.getCmp('tab_emprunts_'+this.id_dossier);
                            tab.removeAll(true);
                            var nt = new EmpruntsPanel(action.result.data.emprunts);
                            tab.add(nt);
                        }
                    }

                    }
                }
            }
        });

        DossierPanel.superclass.initComponent.call(this);
        console.log(this.events)
    }
});

Here's my problem: as long as the tabs are not shown, the data contained within the tabs are not sent. If I click on a tab, the data is added to the "stack" and is sent through the post event. (See the code)
What I don't get is that I'm using "deferredRender: false". This seems it's the only thing to use to "force" field calculation. I don't see what I'm missing, but I'm missing something.
Can anyone help me?

Thanks a lot.

Here's the full source code (that works) of the DossierPanel class:

DossierPanel = Ext.extend(Ext.form.FormPanel, {
    closable: true,
    autoScroll:true,

    initComponent : function(){
        var n = this.id_dossier;
        if (this.nom) {
            n += ' '+this.nom
        }
        if (this.prenom) {
            n += ' '+this.prenom;
        }
        this.title = n;
        this.id = 'id_dossier_'+this.id_dossier;
        this.bodyStyle = 'padding:15px';
        this.labelWidth = 150;
        this.items = [{
            layout:'column',
            border:false,
            autoHeight: true,
            items:[{
                columnWidth:.5,
                layout: 'form',
                border:false,
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'Civilite ',
                    name: 'CIVILITE',
                    readOnly: true
                }, {
                    xtype:'textfield',
                    fieldLabel: 'Nom ',
                    name: 'NOM',
                    anchor:'95%'
                }, {
                    xtype:'textfield',
                    fieldLabel: 'Prenom ',
                    name: 'PRENOM',
                    anchor:'95%'
                }]
            },{

                columnWidth:.5,
                layout: 'form',
                border:false,
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'RaisonSociale ',
                    name: 'RAISONSOCIALE',
                    anchor:'95%'
                },{
                    xtype:'textfield',
                    fieldLabel: 'Email ',
                    name: 'EMAIL',
                    vtype:'email',
                    anchor:'95%'
                }]
            }]
        },{
            xtype:'tabpanel',
            plain:true,
            activeTab: 0,
            /* (!) For a tab to force calculation, I use
             * deferredRender: false
             * It's very important for Form with multiple Tabs
             */
            deferredRender: false,
            defaults:{bodyStyle:'padding:10px'},
            items:[{
                title:'Détails personnels',
                layout:'form',
                autoHeight: true,
                defaults: {width: '99%'},
                defaultType: 'textfield',

                items: [{
                    fieldLabel: 'Poids ',
                    name: 'POIDS',
                    readOnly: true
                }, {
                    xtype:'datefield',
                    fieldLabel: 'Date premier contact ',
                    name: 'DATE1ERCONTACTJMA',
                    readOnly: true,
                    format:'d/m/Y'
                }, {
                    xtype:'datefield',
                    fieldLabel: 'Date étude dossier ',
                    name: 'DATEDATE_ETUDE_DOSSIERJMA',
                    format:'d/m/Y'
                }]
            },{
                title:'Adresse',
                layout:'form',
                autoHeight: true,
                defaults: {width: '95%'},
                defaultType: 'textfield',
                items: [{
                    fieldLabel: 'Adresse 1 ',
                    name: 'ADRESSE1'
                }, {
                    fieldLabel: 'Pays ',
                    name: 'PAYS',
                    readOnly: true
                }]
            },{
                title:'Téléphone(s)',
                layout:'form',
                autoHeight: true,
                defaults: {width: 230},
                defaultType: 'textfield',
                items: [{
                    fieldLabel: 'NoTelephone2 ',
                    name: 'NOTELEPHONE2',
                }, {
                    fieldLabel: 'DescTelephone3 ',
                    name: 'DESCTELEPHONE3',
                    readOnly: true
                }, {
                    fieldLabel: 'NoTelephone3 ',
                    name: 'NOTELEPHONE3',
                }]
            },{
                title:'Divers',
                layout:'form',
                autoHeight: true,
                defaults: {width: 230},
                defaultType: 'textfield',
                items: [{
                    fieldLabel: 'Mot de passe Internet ',
                    name: 'MOTDEPASSE'
                }, {
                    fieldLabel: 'Parts ',
                    name: 'PARTS'
                }, {
                    fieldLabel: 'Commission ',
                    name: 'COMMISSION'
                }]
            },{
                id: 'tab_emprunts_'+this.id_dossier,
                title:'Emprunts',
                layout:'form',
                autoHeight: true,

                defaults: {width: '99%'},
                defaultType: 'textfield',
                items: []
            }]
        }];
        this.buttonAlign = 'left';
        this.buttons = [{
            text: 'Recharger',
            handler: function() {
                this.getForm().load( {
                  url: '/ws/cellulemedicale/jsonEditDossier.php',
                  params: {
                      id_dossier: this.id_dossier
                  },
                  waitTitle: 'Wait',
                  waitMsg: 'Refresh',
                  failure:function(form, action) {
                        globGestionErreurAjax(action.response,'Refresh error');
                  }
                });
            },
            scope: this
        },{
            text: 'Sauver',
            handler: function() {
                this.getForm().submit({
                    url: '/ws/cellulemedicale/jsonEditDossier.php',
                    params: {
                        write: 1,
                        id: this.id_dossier
                    },
                    waitTitle: 'Wait...',
                    waitMsg: 'Saving',
                    success: function (form, action) {
                      var b = Ext.util.JSON.decode(action.response.responseText);
                      if (b.success==true) {
                          if (b.msg) {
                              Ext.MessageBox.alert('Done!', b.msg);
                          }
                          else {
                              Ext.MessageBox.alert('Done!', 'Saved ok');
                          }
                      }
                    },
                    failure:function(form, action) {
                        globGestionErreurAjax(action.response,'Save error');
                    }
                });
            },
            scope: this
        }];
        this.on('actioncomplete', function (form,action) {
            if (action.type=='load') {
                console.log(action.result.data.emprunts);
                if(typeof action.result != 'undefined') {
                    if(typeof action.result.data != 'undefined') {
                        if(typeof action.result.data.emprunts != 'undefined') {
                            /* For now, use the id, this may be ugly:
                             */
                            var tab = Ext.getCmp('tab_emprunts_'+this.id_dossier);
                            tab.removeAll(true);
                            var nt = new EmpruntsPanel(action.result.data.emprunts);
                            tab.add(nt);
                        }
                    }

                    }
                }
            }
        });

        DossierPanel.superclass.initComponent.call(this);
        console.log(this.events)
    }
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

流殇 2024-11-06 13:50:46

如何将 forceLayout: true 配置属性添加到每个选项卡或选项卡面板本身?

我希望这会导致计算字段。

how about adding the forceLayout: true config property to each of the tabs or the tabpanel itself?

I'm hoping this would cause the fields to be calculated.

未蓝澄海的烟 2024-11-06 13:50:46

我认为您需要将其包含

defaults: { hideMode: 'offsets' }

在选项卡面板中。

I think you need to include

defaults: { hideMode: 'offsets' }

in your tab panel.

够运 2024-11-06 13:50:46

我认为你需要设置 is Dirty = true

{ xtype: 'textfield', name: 'name' ,readOnly:true ,submitValue: true ,isDirty: function() { return true;} }

I think u need set is Dirty = true

{ xtype: 'textfield', name: 'name' ,readOnly:true ,submitValue: true ,isDirty: function() { return true;} }

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文