0

私はExtJS3.3を使用しており、次のコードを使用していますformpanel

Ext.apply(this, {
    items: [{
            xtype: 'textfield',
            fieldLabel: 'ApplicationGUID',
            labelAlign: 'right',
            name: 'Application_GUID',
            value: 0,
            readOnly: false,
            width: 300
        },
        {
            xtype: 'textfield',
            fieldLabel: 'ApplicationName',
            labelAlign: 'right',
            name: 'Application_Name',
            anchor: '-20',
            msgTarget: 'side'
        }

    ], //eof items
    tbar: [{
        xtype: 'mydeletebutton',
        scope: this,
        ownerCt: this,
        handler: this.deleteHandler,
        myAuth: {
            compBaseRights: {
                Delete: {
                    failProperty: {
                        disabled: false
                    }
                } /*eof Delete*/
            } /*eof compBaseRights*/
        } /*eof sgAuth*/
    }, {
        xtype: 'tbseparator'
    }, {
        xtype: 'trashcanbutton',
        scope: this,
        ownerCt: this,
        handler: this.setIsDeletedHandler,
        myAuth: {
            compBaseRights: {
                Insert: {
                    failProperty: {
                        disabled: false
                    }
                } /*eof Delete*/
            } /*eof compBaseRights*/
        }
    }, {
        xtype: 'mytrashcanrestorebutton',
        scope: this,
        ownerCt: this,
        handler: this.unsetIsDeletedHandler,
        myAuth: {
            compBaseRights: {
                Insert: {
                    failProperty: {
                        disabled: false
                    }
                } /*eof Delete*/
            } /*eof compBaseRights*/
        }
    }, {
        xtype: 'tbseparator'
    }, {
        xtype: 'mysavebutton',
        scope: this,
        handler: this.saveHandler,
        myAuth: {
            compBaseRights: {
                Write: {
                    failProperty: {
                        disabled: false
                    }
                } /*eof Delete*/
            } /*eof compBaseRights*/
        }
    }],
    bbar: {
        xtype: 'mystatusbar'
    }
});

私が探しているのは、textfieldApplication_GUIDのreadOnly: true場合、値がすでに存在するかどうか(グリッドから既存の値をダブルクリックして編集する場合など)である必要があり、から新しいボタンを押すとgridreadonlyステートメントはである必要がありますfalse

誰かが私を助けることができれば、それはありがたいです。ありがとう。

4

1 に答える 1

1

良いテクニックは、ブール変数をfalseとして初期化するように設定することです。次に、必要に応じてtrueに設定します。

次に、次のサンプルコードのように、必要なリスナーを追加します。たとえば、変更リスナーに追加します。

listeners: {
    yourlistener: function(e) { //yourlistener can be change, select, etc...
        if (booleanVariable === true) Ext.getCmp('your-textbox-id').setReadOnly(true);
        else Ext.getCmp('your-textbox-id').setReadOnly(false);
    }
 }
于 2012-06-26T14:13:31.887 に答える