日期:2014-05-16  浏览次数:21023 次

ext.paginggridpanel后台代码怎么写。 - Web 开发 / Ajax
如题,希望高手们能给个详细的代码。。谢谢。。

------解决方案--------------------
JScript code

var store = new Ext.data.JsonStore({
        root: 'topics',//根
        totalProperty: 'totalCount',//总页数
        idProperty: 'threadid',
        remoteSort: true,

        fields: [
            'title', 'forumtitle', 'forumid', 'author',
            {name: 'replycount', type: 'int'},
            {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
            'lastposter', 'excerpt'
        ],

        // load using script tags for cross domain, if the data in on the same domain as
        // this page, an HttpProxy would be better
        proxy: new Ext.data.ScriptTagProxy({
            url: 'http://extjs.com/forum/topics-browse-remote.php'
        })
    });
    store.setDefaultSort('lastpost', 'desc');

/**
后台code返回数据格式:
{totalCount:"总页数"topics:[{和fields中的数据对应}]}
*/
var pagingBar = new Ext.PagingToolbar({
        pageSize: 25,
        store: store,
        displayInfo: true,
        displayMsg: 'Displaying topics {0} - {1} of {2}',
        emptyMsg: "No topics to display",
        
        items:[
            '-', {
            pressed: true,
            enableToggle:true,
            text: 'Show Preview',
            cls: 'x-btn-text-icon details',
            toggleHandler: function(btn, pressed){
                var view = grid.getView();
                view.showPreview = pressed;
                view.refresh();
            }
        }]
    });

store.load({params:{start:0, limit:25}});//从后台获得参数,从start哪页开始显示,limit每页显示多少条记录
参考:http://blog.csdn.net/dwj520/archive/2009/12/12/4994411.aspx
http://hi.baidu.com/%CB%B9%CE%C4%B5%C4%BB%D2%C9%AB%BF%D5%BC%E4/blog/item/ebeae13510c46d80a71e127a.html