首页 > 代码库 > 前台分页

前台分页

        var dg = $(this);
                        var opts = dg.datagrid(‘options‘);
                        var pager = dg.datagrid(‘getPager‘);
                        pager.pagination({
                            onSelectPage:function(pageNumber,pageSize) {
                                opts.pageNumber = pageNumber;
                                opts.pageSize = pageSize;

                                pager.pagination(‘refresh‘, {
                                    pageNumber:pageNumber,
                                    pageSize:pageSize
                                });
                                dg.datagrid(‘loadData‘, result);
                            }
                        });

                        if (!result.originalRows){
                            result.originalRows = (result.rows);
                        }

                        var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
                        var end = start + parseInt(opts.pageSize);
                        result.rows = (result.originalRows.slice(start, end));

                        return result;
                    },

 

前台分页