PagingToolbar 不读取数据 - Ext JS

Posted

技术标签:

【中文标题】PagingToolbar 不读取数据 - Ext JS【英文标题】:PagingToolbar not reading Data - 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 );
    
)

帮助?

【问题讨论】:

【参考方案1】:

尝试使用Ext.ux.data.PagingMemoryProxy

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

【讨论】:

以上是关于PagingToolbar 不读取数据 - Ext JS的主要内容,如果未能解决你的问题,请参考以下文章

Ext js分页全显了有界面没有分页,不用数据库和后台怎么做

cordova-sqlite-ext 可以读取 sd 卡(Android)上的数据库吗?

EXT2 文件系统

《Linux杂记》Window读取 Ext3/Ext4文件系统数据

java 做进度条 ajax实现 js jquery ext 都可以需要具体实现过程和代码 需要读取数据

ExtJs之Ext.comboBox的远程数据源读取程序