我正在构建一个应该在手机/平板电脑/PC 上运行的应用程序。主要功能包含我从另一台服务器上托管的 json 文件中获取的大量项目列表。目前我正在使用 PC 并且该列表需要大约一分钟来填充(超过 800 个对象,这个数字每天都在增长),我猜这是因为生成 800 个 div 的标记需要时间......
注意:我在本地工作,当它在线时,这将是一场噩梦,矫枉过正..
我的想法是从 json 中获取所有数据,但在列表中显示数量有限的项目(比如 30 个)。但是,为了能够搜索和过滤所有这些,并且仍然只显示 30 个项目 MAX。
下面的代码正在工作,没有我想要的限制选项:
        //model
    Ext.define('User', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {name: 'Name', type: 'string'},
                {name: 'Address', type: 'string'},
                {name: 'ID', type: 'int'},
                {name: 'WebUrl', type: 'string'},
                {name: 'InfoUrl', type: 'string'},
                ]
        }
    });
    //store
    store = Ext.create('Ext.data.Store', {
        model: 'User',
        sorters: 'Name',
        grouper: {
            groupFn: function(record) {
                return record.get('Name')[0];
            }
        },
        proxy: {
            type: 'ajax',
            url: 'http://localhost:8088/Services/RestaurantList.ashx',
            reader: {
                type: 'json',
                rootProperty: 'users'
            }
        },
        autoLoad: true
    });
    //the list
    list = Ext.create('Ext.List', {
        flex: 2,
        itemTpl: ['<div class="contact">{Name}</div>'],
        store: store,
        listeners: {
                        itemtap: function(list, index, target, record) {
                            mainContainer.setActiveItem(1);
                            detailsPanel.setRecord(record);
                        }
                    },
        grouped: true,
/* maxVisibleRecords: 30,
limit: 30,
params: { limit: 30 },
ExtraParams: { limit: 30} */ //none worked
    });
谢谢!:)