Sencha Touch面板列表

时间:2011-09-19 11:53:28

标签: sencha-touch

我有一个应用程序设置,并在我的锄页/屏幕上有几个链接。当我点击一个链接时,它会显示一个项目列表(如联系人列表),然后再点击列表项目时的详细视图。

我有以下设置:

  App.views.Viewport = Ext.extend(Ext.Panel, {
   fullscreen: true,
   layout: 'card',
   cardSwitchAnimation: 'slide',
   dockedItems: [
       {
        dock : 'top',
        xtype: 'toolbar',
        title: '<img src="res/img/generic/TT_Small.png" />',
        cls: 'homeHeader'
       },
    ],

 });

我想要的视图是:

  App.views.HomeAbout = Ext.regModel('Contact', {
  fields: ['firstName', 'lastName']
  });

  var store = new Ext.data.JsonStore({
  model : 'Contact',
  root: 'images',
  sorters: 'firstName',

  getGroupString : function(record) {
  return record.get('firstName')[0];
  },


  data: [
  {firstName: 'Tommy', lastName: 'Maintz'},
  {firstName: 'Rob', lastName: 'Dougan'},
  {firstName: 'Ed', lastName: 'Spencer'},
  {firstName: 'Jamie', lastName: 'Avins'},
  {firstName: 'Aaron', lastName: 'Conran'},
  {firstName: 'Dave', lastName: 'Kaneda'},
  {firstName: 'Michael', lastName: 'Mullany'},
  {firstName: 'Abraham', lastName: 'Elias'},
  {firstName: 'Jay', lastName: 'Robinson'}
  ]
  });

var list = new Ext.List({       全屏:真的,       itemTpl:'{firstName} {lastName}',             分组:真的,       indexBar:false,

  store: store
  });

我正在使用简单的“联系方式”,例如开始运行,因此一旦运行,我将根据需要修改我的数据等,但是当我点击链接转到此视图时,我得到以下内容

  Uncaught Attempting to create a component with an xtype that has not been registered: HomeAbout

但在我的控制器里我有:

  about: function()
{
    if ( ! this.aboutView)
    {
        this.aboutView = this.render({
            xtype: 'HomeAbout',
        });
    }.....

任何想法或帮助将不胜感激

1 个答案:

答案 0 :(得分:1)

首先改变:

App.views.HomeAbout = Ext.regModel('Contact', {
  fields: ['firstName', 'lastName']
 });

App.models.Contact = Ext.regModel('Contact', {
  fields: ['firstName', 'lastName']  
});   

然后有这个

App.views.HomeAbout = Ext.extend(Ext.List, { 
    fullscreen: true,
    itemTpl : '{firstName} {lastName}',
    grouped : true,
    indexBar: false, 
    store: store
});

而不是var list...

最后注册了新的xtype - 扩展默认的sencha-touch类的类 - 就像这个

Ext.reg('HomeAbout', App.views.HomeAbout);