1

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

これは私のコードです:

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);

誰かがコードのどこに問題があるのか​​教えてもらえますか?

4

2 に答える 2

2

これがデモ付きのコードです。期待どおりに動作します。呼び出すときに JS エラーがあるかどうかを確認することをお勧めconceptPropertiesPanel.setSourceData(data);ます

于 2011-08-31T15:56:52.703 に答える
0

ここでの推測ですが、オブジェクトが既に初期化された後に Source を設定することになるため、オブジェクトの への更新を見つけるupdate()doLayout()、データの表示を更新する必要があります。

別のオプションは、元の関数呼び出しで構成を取得することです。何かのようなもの:

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"
};
于 2009-07-13T20:27:17.550 に答える