2013-03-06 4 views
1

내 ListItems는 텍스트가없는 공백으로 나타납니다.Sencha Touch 2 : ListItems가 비어 있습니다.

처음에는 항목이 {field_name}을 (를) 사용하여 List 개체의 itemTpl 정의로 간단하게 형식이 지정되었습니다. 이것은 잘 작동했지만 물론 기능면에서 제한적이었습니다.

그래서 DataMap을 사용하여 DataView (http://docs.sencha.com/touch/2-1/#!/guide/dataview)의 ST2 설명서를 살펴본 후이를 복제하려고했습니다. 그러나 어떤 이유로 든 실제로 렌더링 할 수없는 콘텐츠를 얻는 것처럼 보입니다. 예상되는 결과 수가 나타나고 공개 조치로 올바른/해당 레코드가 열립니다. 항목이 모두 텍스트없이 비어있는 것입니다.

저장소는 프록시를 통해 JSON 데이터를로드합니다. 데이터에는 "캡션"이라고하는 것을 포함하여 많은 필드가 있습니다. 지금은 목록 항목에서 스타일을 지정하고 표시하고 싶습니다. '캡션'콘텐츠를 기반으로하면 스타일을 다르게 적용 할 수 있습니다.

언제나처럼, 모든 도움을 주시면 대단히 감사하겠습니다. 감사!

모함마드.

마이리스트 객체

산호세, CA

:

Ext.define('qxtapp.view.ResultsList', { 
    extend: 'Ext.dataview.List', 
    alias: 'widget.resultsList', 
    xtype: 'resultsList', 
    requires: [ 
     'qxtapp.view.ResultsListItem', 
     'Ext.plugin.ListPaging' 
    ], 

    config: { 
     defaultType: 'resultslistitem', 
     loadingText: 'Performing search...<br>This may take up to 1 minute.', 
     emptyText: 'No results found.', 
     useComponents: true, 
     store: 'SearchResults', 
     onItemDisclosure: true, 
     plugins: [ 
      { 
       xclass: 'Ext.plugin.ListPaging', 
       autoPaging: true 
      } 
     ] 
    } 
}); 

내을 ListItem 개체 :

Ext.define('qxtapp.view.ResultsListItem', { 
    extend: 'Ext.dataview.component.ListItem', 
    xtype : 'resultslistitem', 

    config: { 
     captionPanel: true, 
     dataMap: { 
      getCaptionPanel: { 
       setText: 'caption' 
      } 
     } 
    }, 
    applyCaptionPanel: function(config) { 
     return Ext.factory(config, Ext.Panel, this.getCaptionPanel()); 
    }, 
    updateCaptionPanel: function(newCaptionPanel, oldCaptionPanel) { 
     if(oldCaptionPanel) { 
      this.remove(oldCaptionPanel); 
     } 
     if(newCaptionPanel) { 
      this.add(newCaptionPanel); 
     } 
    } 
}); 

답변

1

신경 쓰지 마, 난 내 자신의 실수를 깨달았다.

데이터 맵 내부의 벙어리 실수. 내 설정을 Panel이 아닌 Button으로 변환하기 때문에, 내 setter는 "setText"가 아니라 "setHtml"이어야합니다. 이제 작동합니다.

감사합니다.

dataMap: { 
     getCaptionPanel: { 
      setText: 'caption' // <---- should have been "setHtml:..." 
     } 
    } 
+0

이것은 내 시나리오에도 도움이되었습니다. thnx –