1

我正在研究一个简单的 PropertyGrid。如果我在设计时使用一些 json 对象设置源属性,它会正确显示。但是当我尝试动态设置源数据时,它没有显示数据。

这是我的代码:

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

Just a guess here, but that would be setting Source after the object is already initialized, which would require you to find the object's update to update(), or doLayout() to update the presentation of the data.

Another option is in your original function call to take a config. Something like:

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 回答