首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PagingToolbar未读取数据- Ext JS

PagingToolbar未读取数据- Ext JS
EN

Stack Overflow用户
提问于 2014-03-12 04:25:42
回答 1查看 47关注 0票数 0

在这里,我似乎无法让PagingToolbar在我的网格上正常工作。无论如何,它会告诉我返回了0个结果,即使我正在找回我所有的数据。

代码语言:javascript
复制
Ext.onReady(function() {
    var data = '{"elements":[{"element":{"name":"value 1","id":"element 1","attributes":[{"attrname":"id","attrvalue":"This is the ID"},{"attrname":"name","attrvalue":"This is the name"},{"attrname":"description","attrvalue":"This is the description"},{"attrname":"table_name","attrvalue":"This is the table"}]}},{"element":{"name":"value 2","id":"element 2","attributes":[{"attrname":"id","attrvalue":"This is the ID 2"},{"attrname":"name","attrvalue":"This is the name 2"},{"attrname":"description","attrvalue":"This is the description 2"},{"attrname":"table_name","attrvalue":"This is the table 2"}]}}]}';
    var store = Ext.create('Ext.data.Store', {
        fields: ['id', 'name', 'description', 'table_name'],
        proxy: {
            type: 'memory'
        }
    })
    Ext.create('Ext.grid.Panel', {
        title: 'Test Data',
        store: store,
        pageSize: 2
        columns: [{
            text: 'ID',
            dataIndex: 'id'
        }, {
            text: 'Name',
            dataIndex: 'name'
        }, {
            text: 'Description',
            dataIndex: 'description'
        }, {
            text: 'Table Name',
            dataIndex: 'table_name'
        }],
        dockedItems: [{
            xtype: 'pagingtoolbar',
            store: store,
            pageSize: 2,
            dock: 'bottom',
            displayInfo: true
        }]
        renderTo: Ext.getBody()
    });
    var decoded = Ext.decode( data );
    // loop over decoded data
    for( var i=0; i<decoded.elements.length; i++ ) {
        var element = decoded.elements[ i ].element;
        // set implicit model
        var model = {};
        // loop over attributes
        for( var x=0; x<element.attributes.length; x++ ) {
            var attribute = element.attributes[ x ];
            model[ attribute.attrname ] = attribute.attrvalue;
        }
        // implicitly cast data as Model
        store.add( model );
    }
})

帮助?

EN

回答 1

Stack Overflow用户

发布于 2014-03-12 04:29:09

尝试使用Ext.ux.data.PagingMemoryProxy

分页内存代理,允许在内存数据集

中使用分页网格

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22335879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档