【问题标题】:PagingToolbar not reading Data - Ext JSPagingToolbar 不读取数据 - Ext JS
【发布时间】:2014-03-11 20:25:41
【问题描述】:

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

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 );
    }
})

帮助?

【问题讨论】:

    标签: extjs


    【解决方案1】:

    尝试使用Ext.ux.data.PagingMemoryProxy

    分页内存代理,允许在内存数据集中使用分页网格

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-14
      相关资源
      最近更新 更多