2009-07-10 6 views
1

저는 단순한 PropertyGrid에서 작업하고 있습니다. 디자인 타임에 일부 json 객체로 source 속성을 설정하면 제대로 표시됩니다. 그러나 원본 데이터를 동적으로 설정하려고 시도했을 때 데이터가 표시되지 않습니다. 나는 'setSourceData'함수를 호출하고 어떻게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" 
    }); 
} 

}); 

이것은 :

이 내 코드입니다.

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

누구든지 내게 문제가있는 코드를 알려주십시오.

답변

0

개체가 이미 초기화 된 후에 소스를 설정하면 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" 
}; 
+0

doLayout()을 사용해 보았지만 작동하지 않습니다. 또한 위 코드를 사용하십시오. 그러나 동일한 행동. 필요한 기능을 수행하는 다른 방법이 있습니까? –

2

Here은 데모가 포함 된 코드입니다. 그것은 예상대로 작동합니다. conceptPropertiesPanel.setSourceData(data);을 호출 할 때 JS 오류가 있는지 확인해야 할 수도 있습니다. 그렇지 않으면 이어야합니다.

관련 문제