sencha-touch-2 - 列表不显示

标签 sencha-touch-2

我无法在我的 View 中显示列表。看来我正在从 ajax 调用中获取数据。 我肯定在这里遗漏了一些东西。请帮忙。谢谢

详情如下: 数据:

Stations.json

[
{
    "id": "129",
    "stop": "NY Station",
},
{
    "id": "13",
    "stop": "Newark Station",
}

]

型号:

Ext.define('MyApp.model.Station', {
extend: 'Ext.data.Model',

config: {
    fields: [
         {name: 'id',  type: 'string'},
     {name: 'stop',  type: 'string'}

     ]
}

});

商店:

       Ext.define('MyApp.store.Stations', {
       extend  : 'Ext.data.Store',
       requires: ['MyApp.model.Station'],
    id: 'stations',
    xtype: 'stations',
    config  : {
        model : 'MyApp.model.Station',
        storeId: 'stationsStore',
        autoLoad : true,
        //sorters: 'stop',
        proxy: {
                type: 'ajax',
                url: 'Stations.json'

     }
     });

View:

Ext.define('MyApp.view.MyService', {
extend: 'Ext.Panel',
xtype: 'stationsformPage',
fullscreen: true,
layout: 'vbox',
requires: [
    'MyApp.store.Stations',    
    'Ext.form.FieldSet',
    'Ext.field.Password',
    'Ext.SegmentedButton',
    'Ext.List'
  ],

config: {
    iconCls: 'settings',
    title: 'My Service',
   items: [
        {
            docked: 'top',
            xtype: 'toolbar',
            title: 'My Service'
        },

        {
            xtype: 'list',
            title: 'Stations',
            store: 'stationsStore',
            styleHtmlContent: true,
            itemTpl: '<div><strong>{stop}</strong> {id}</div>'

        },

    ]
   },
   initialize: function() {

        /*
        Ext.Ajax.request({
            scope : this,
            url: 'StationLocator.json',
            callback : function(options, success, response){
                    var json =   Ext.decode(response.responseText);
                    alert(response.responseText); //this works
                    alert(json[0].stop); //this works
            }
        });
        */

  }//initialize

  });

最佳答案

我把它放在 TabPanel 中。这会有帮助吗?它看起来像这样:

enter image description here

这是我的观点:

Ext.define('MyApp.view.MyService', {
    extend: 'Ext.tab.Panel',
    xtype: 'stationsformPage',
    fullscreen: true,
    layout: {
        pack: 'center'
    },
    requires: [
        'MyApp.store.Stations',
        'Ext.form.FieldSet',
        'Ext.field.Password',
        'Ext.SegmentedButton',
        'Ext.List'
    ],
    config: {
      tabBarPosition:'bottom',
        layout: {
            type: 'card',
            animation: {
                duration: 300,
                easing: 'ease-in-out',
                type: 'slide',
                direction: 'left'
            }
        },
        fullscreen: true,
        title: 'My Service',
        items: [
            {
                docked: 'top',
                xtype: 'toolbar',
                title: 'My Service'
            },

            {
                xtype: 'list',
                title: 'Stations',
                store: 'stationsStore',
//                height: 600,
//                width: 400,
//                style: 'background-color: #c9c9c9;',
                styleHtmlContent: true,
                itemTpl: '{stop} {id}'

            }

        ]
    }

});




这是将列表放在常规面板中的版本:

enter image description here

Ext.define('MyApp.view.MyService', {
    extend: 'Ext.Panel',
    xtype: 'stationsformPage',
    fullscreen: true,
    layout: {
        pack: 'center'
    },
    requires: [
        'MyApp.store.Stations',
        'Ext.form.FieldSet',
        'Ext.field.Password',
        'Ext.SegmentedButton',
        'Ext.List'
    ],
    config: {

        fullscreen: true,
    layout: 'fit', // Specifying fit is important.  Won't see list without it
        title: 'My Service',
        items: [
            {
                docked: 'top',
                xtype: 'toolbar',
                title: 'My Service'
            },

            {
                xtype: 'list',
                store: 'stationsStore',

                styleHtmlContent: true,
                itemTpl: '{stop} {id}'

            }
        ]
    }
});

关于sencha-touch-2 - 列表不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10541475/

相关文章:

sencha-touch-2 - 删除 Sencha Touch 上的 Android 工具栏

javascript - Extjs:如何获取表单的值

sencha-touch - 如何使用 Sencha Touch 上传照片图像而无需手机间隙

sencha-touch - 如何在不使用 AJAX 的情况下将数据发布到 Sencha Touch 中的服务器

javascript - Sencha touch 2- Ext.dispatch 替代品?

javascript - Sencha Touch itemtap 详细信息查看

themes - Sencha Touch 2 标准主题?

cordova - 使用 OAuth2 联系 Google API 时的 Redirect_uri_mismatch

extjs - 初始化和解构 Controller 的最佳实践

css - Android 平板电脑中的 Sencha 触摸面板滚动性问题