Javascript ExtJS PropertyGrid-动态设置源
我正在做一个简单的PropertyGrid。如果在设计时使用某个json对象设置source属性,它将正确显示。但是当我尝试动态设置源数据时,它没有显示数据 这是我的代码:Javascript ExtJS PropertyGrid-动态设置源,javascript,extjs,propertygrid,Javascript,Extjs,Propertygrid,我正在做一个简单的PropertyGrid。如果在设计时使用某个json对象设置source属性,它将正确显示。但是当我尝试动态设置源数据时,它没有显示数据 这是我的代码: ConceptPropertiesPanel = function() { this.source = { ***// if i set source this way, it will work*** "(name)": "My Object", "Created": new Date(Da
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);
有人能告诉我代码中的问题在哪里吗?这里只是一个猜测,但这将是在对象已经初始化之后设置源代码,这将要求您找到对象的更新到
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"
};
是您的代码与演示。它按预期工作。您可能希望在调用conceptPropertiesPanel.setSourceData(数据)时检查是否存在任何JS错误代码>否则它应该工作 我试过使用doLayout()但它不起作用。另外,使用上述代码。但同样的行为。是否有实现所需功能的替代方法。