2009-07-10 24 views
1

私は単純なPropertyGridで作業しています。デザイン時にjsonオブジェクトを使ってsourceプロパティを設定すると、正しく表示されます。しかし、ソースデータを動的に設定しようとすると、データが表示されません。ExtJS PropertyGrid - 動的にソースを設定する

これは私のコードです:

ConceptPropertiesPanel = function() { 

    this.source = { ***// if i set source this way, it will work*** 

    "(name)": "My Object", 
    "Created": new Date(Date.parse('10/15/2006')), 
    "Available": false, 
    "Version": .01,  
    "Description": "A test object" 
}; 

ConceptPropertiesPanel.superclass.constructor.call(this, { 
    id: 'concetp-properties', 
    region: 'east', 
    title: 'Concept Properties', 
    autoScroll: true, 
    margins: '0 5 0 0', 
    split: true, 
    width: 250, 
    minSize: 250, 
    maxSize: 400, 
    collapsible: true, 
    source: {} 
}) 
}; 


Ext.extend(ConceptPropertiesPanel, Ext.grid.PropertyGrid, { 

setSourceData: function(data) { **//I want to set source when the below method is called, but not working** 
    this.setSource({ 
     "(name)": "My Object", 
     "Created": new Date(Date.parse('10/15/2006')), 
     "Available": false, 
     "Version": .01,  
     "Description": "A test object" 
    }); 
} 

}); 

これは私が 'setSourceData' 関数を呼び出しています方法です。

var conceptPropertiesPanel = new ConceptPropertiesPanel(); 
conceptPropertiesPanel.setSourceData(data); 

問題がコード内のどこにあるか教えていただけますか?

答えて

0

オブジェクトの初期化後にSourceを設定すると、オブジェクトの更新をupdate()、またはdoLayout()に変更してデータの表示を更新する必要があります。

もう1つのオプションは、元の関数呼び出しでconfigをとることです。次のようなものがあります。

ConceptPropertiesPanel = function(config) { 

this.source = config || { ***// if i set source this way, it will work*** 

    "(name)": "My Object", 
    "Created": new Date(Date.parse('10/15/2006')), 
    "Available": false, 
    "Version": .01,  
    "Description": "A test object" 
}; 
+0

doLayout()を使用しようとしましたが、動作しません。 また、上記のコードで。同じ行動です。 必要な機能を実現する別の方法はありますか? –

2

Hereはデモ版のコードです。それは期待どおりに動作します。 conceptPropertiesPanel.setSourceData(data);を呼び出すときにJSエラーがあるかどうかを確認したい場合は、にする必要があります。

関連する問題