ExtJS 4.1无限网格滚动不起作用

时间:2013-06-04 14:31:56

标签: javascript extjs infinite-scroll

我想用extjs4和一个c#后端获得无限滚动网格...我在我的控制器中设置代理api ..

我的模特:

Ext.define('SCT.model.training.course.TrainingRequirementList', {
    extend: 'Ext.data.Model',
    idProperty: 'ID',
    fields: [
        { name: 'ID', type: 'int', convert: null },
        { name: 'EmployeeName', type: 'string' },
        { name: 'Description', type: 'string' },
        { name: 'StatusText', type: 'string' },
        { name: 'Status', type: 'int' },
        { name: 'Priority', type: 'string' },
        { name: 'Date', type: 'string' },
        { name: 'Cost', type: 'string' },
        { name: 'CanApprove', type: 'bool' },
        { name: 'CanRequest', type: 'bool' },
        { name: 'ConfirmStatus', type: 'string' },
        { name: 'PlanId', type: 'int'}
    ]

});

我的网格:

{
    xtype: 'gridpanel',
    flex: 1,
    padding: '0 10 10 10',
    minHeight: 200,
    verticalScroller: {
        xtype: 'paginggridscroller'
    },
    store: {
        model: 'SCT.model.training.course.TrainingRequirementList',
        pageSize: 200,
        autoLoad: true,

        remoteSort: true,
        sorters: {
            property: 'Date',
            direction: 'DESC'
        },

        proxy: {
            type: 'direct',
            extraParams: {
                total: 50000
            },
            reader: {
                type: 'json',
                root: 'ID',
                totalProperty: 'totalCount'
            },
            simpleSortMode: true
        }
    },
    columns:
        [{
            text: Lang.Main.Employeee,
            dataIndex: 'EmployeeName',
            flex: 1,
            filterable: true
        },
        {
            text: Lang.Main.Course,
            dataIndex: 'Description',
            flex: 1,
            filterable: true
        },
        {
            text: Lang.Main.Status,
            dataIndex: 'StatusText',
            flex: 1,
            filterable: true
        },
        {
            text: Lang.Main.Priority,
            dataIndex: 'Priority',
            flex: 1
        },
        {
            text: Lang.Main.Date,
            dataIndex: 'Date',
            flex: 1
        },
        {
            text: Lang.Main.Cost,
            dataIndex: 'Cost',
            flex: 1,
            filterable: true
        },
        {
            text: Lang.Main.Actions,
            flex: 1,
            align: 'center',
            xtype: 'actioncolumn',
            width: 50,
            items: [{
                icon: 'Design/icons/cog_edit.png',
                tooltip: Lang.Main.Open,
                handler: function (grid, rowIndex, colIndex, item) {
                    this.onGridOpen(grid.getStore().getAt(rowIndex));
                }
            }]
        }],      
    selModel: { mode: 'MULTI', selType: 'checkboxmodel' },
}

在controoler中设置代理:

view.grid.getStore().setProxy({
            type: 'direct', 
            model: 'SCT.model.training.course.TrainingRequirementList', 
            api: { read: SCT.Service.Training.Plan.GetFilteredRequirements }, 
            extraParams: { total: 50000 }, 
            reader: {
                type: 'json',
                root: 'ID',
                totalProperty: 'totalCount'
            },
            simpleSortMode: true
        });

有关我观点的其他信息:

Ext.define('SCT.view.training.course.TrainingRequirements',
    {
        extend: 'Ext.panel.Panel',
        require: [ 'Ext.grid.PagingScroller', 'Ext.ux.grid.FiltersFeature'],

我的网格仍然一次加载所有数据(约8000行......)...... 我已经搜索了解决方案并完成了教程..我仍然没有得到它。

请帮帮我......我完全不懂......

更新

这是我的srv请求: enter image description here

并且响应得到3MB(大约8k数据集......).. ??

1 个答案:

答案 0 :(得分:1)

您的请求转储显示Ext有效地发送了limit参数,因此您的服务器没有处理它......

只是一条建议,但你应该考虑升级到Ext的最后一个版本,因为缓冲grid seems to have been simplified,这样可以避免在你最终升级时重做它。