2017-01-11 6 views
1

私は自分のアプリケーションにExtJsを使用しています。私はいくつかのフィールドがあるウィンドウを作った。 1つのフィールドは、ウィンドウが表示されるたびに変更される名前です。 しかし、私はボタンをクリックするとウィンドウを破壊していないので、再びレンダリングせずに前のデータのみを表示します。どのように私は新しいデータを確認します。フォームでの私のフィールドのテキストフィールドの値を変更する方法ウィンドウが表示されるたびに

私のコード

コードウィンドウのフィールドを設定するウィンドウ

items: [ 
    { 
     xtype: 'combobox', 
     name: 'Assigned To', 
     queryMode: 'local', 
     store: this.getResourceStore(), 
     displayField: 'svmx_name', 
     labelAlign: 'top', 
     fieldLabel: 'Assigned_To', 
     listeners: { 
      scope: this, 
      select: function (combo, record, index) { 
       var form = display_form.getForm(); 
       var id = record.getId(); 
       form.findField('ResourceId').setValue(id); 
      }, 
      afterrender: function (combo, record, index) { 
       console.log(this.getResourceName()); 
       combo.setValue(this.getResourceName()); 
      }, 
     } 
    }, 

に存在します。

if (!this.win) { 
    this.win = Ext.widget({ 
     xtype: 'editorwindow', 
     resourceStore: Ext.getCmp('scheduler1').getResourceStore(), 
     eventStore: Ext.getCmp('scheduler1').getEventStore(), 
     wrapper: Ext.getCmp('scheduler1').getWrapper(), 
     resourceName: targetResource, 
     startdate: date, 
     targetData: dragSource.data, 
    }); 
} 
this.win.show(); 
+0

これはウィンドウの_show_イベントリスナーで処理しましたか? – scebotari66

+0

どのように@scebotariのアイデアをすることができますか? 現在、私はすでにウィンドウがあるかどうかチェックしています。私はそれを破壊して新しいウィンドウを作成しています。新しいアイデアを探している –

答えて

0

必要なデータを設定するためにconfig objectの独自のウィンドウクラスを定義します。 フレームワークはセッターとゲッター関数を作成します。

Ext.define(MyFieldsWindow, { 
    extend: Ext.window.Window, 
    xtype: 'myfieldswindow', 
    config: { 
     resourceName: '', 
     startdate: null, 
     targetData: null 
    }, 
} 

更新機能では、値を特定のコンポーネントに設定します。 updateResourceNameの機能は次のようになります。

updateResourceName: function (newResourceName, oldResourceName) { 
    var resourceNameCmp = this.getComponent('resourceName'); 
    resourceNameCmp.setValue(newResourceName); 
}, 

これで、インスタンスを作成するときに設定を行うことができます。

if (!this.win) { 
    this.win = Ext.create({ 
     xtype: 'myfieldswindow', 
     resourceStore: Ext.getCmp('scheduler1').getResourceStore(), 
     eventStore: Ext.getCmp('scheduler1').getEventStore(), 
     wrapper: Ext.getCmp('scheduler1').getWrapper(), 
     resourceName: targetResource, 
     startdate: date, 
     targetData: dragSource.data, 
    }); 
} 
this.win.show(); 

また、実行時にsetterメソッドを使用して設定することもできます。

this.win.setResourceName('Roli Agrawal'); 

ウィンドウクラスは次のようになります。

Ext.define(MyFieldsWindow, { 
    extend: Ext.window.Window, 

    config: { 
     resourceName: '', 
     startdate: null, 
     targetData: null 
    }, 

    updateResourceName: function (newResourceName, oldResourceName) { 
     var resourceNameCmp = this.getComponent('resourceName'); 
     resourceNameCmp.setValue(newResourceName); 
    }, 

    updateStartDate: function() {/*similar code like above*/ }, 
    updateTargetDate: function() {/*similar code like above*/ }, 

    items: [ 
     { 
      itemId: 'resourceName', 
      xtype: 'textfield' 
     }, 
     /* additional items*/ 
    ] 
}); 
関連する問題