2013-03-06 118 views
1

我的ListItems始终显示为空白且没有文字。Sencha Touch 2:ListItems为空

最初,我的项目使用{field_name}简单地使用List对象的itemTpl定义进行格式化。这工作正常,但当然功能有限。

因此,我使用dataMap查看了DataView的ST2文档指南(http://docs.sencha.com/touch/2-1/#!/guide/dataview),并试图复制它。但是,无论出于何种原因,我似乎无法获得实际呈现的内容。我得到了预期的结果数量,披露行为确实打开了正确/相应的记录。只是这些项目都是空白的,没有文字。

商店通过代理加载JSON数据。数据有很多领域,其中一个叫做“标题”。现在,这就是我想要的样式和显示在列表项中。基于“标题”内容,我可以对事物进行不同的表述。

像往常一样,任何帮助,非常感谢。谢谢!

穆罕默德。

加利福尼亚州圣何塞,

我的列表对象:

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应该是“setHtml”而不是“setText”。现在工作。

谢谢。

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

这也帮助了我的情景。日Thnx – 2014-06-27 17:09:49