本帖最后由 3wldjnba123 于 2017-2-5 13:36 编辑
- $.get( "http://localhost:8083/v1/work/filte_pager?limit=80&offset=9999909", function ( data, status ) {
- console.log( "data", data, "status", status )
- // create CollectionView on the data (so grid and chart stay in sync)
- var cv = new wijmo.collections.CollectionView( data ),
- pagerButtons = Array.prototype.slice.call( document.querySelectorAll( '#pPager button' ) );
- // 设置page属性
- cv.pageSize = 80;
- var pageCount = 100, //自定义总页数
- pageIndex = 0; //自定义当前页数
- updatePager(); //初始分页按钮
- console.log( cv.pageIndex, cv.pageSize, cv.totalItemCount, cv.itemCount, cv.pageCount, 123 )
- //点击更新页面按钮
- pagerButtons.forEach( function ( el ) {
- el.addEventListener( 'click', function () {
- updatePager( this.getAttribute( 'data-action' ) );
- console.log( cv.pageIndex, cv.pageSize, cv.totalItemCount, cv.itemCount )
- } );
- } );
- // 更新显示文本和禁用/启用分页按钮
- function updatePager( action ) {
- // 通过id获取按钮
- var display = document.getElementById( 'pn' ),
- fb = document.getElementById( 'pfb' ),
- sb = document.getElementById( 'psb' ),
- sf = document.getElementById( 'psf' ),
- ff = document.getElementById( 'pff' ),
- enableBackwards = false,
- enableForwards = false;
- // 处理分页操作基于按钮的属性
- switch ( action ) {
- case 'fast-backward':
- // cv.moveToFirstPage();
- break;
- case 'step-backward':
- // cv.moveToPreviousPage();
- pageIndex -= 1
- break;
- case 'step-forward':
- // cv.moveToNextPage();
- pageIndex += 1
- console.log( pageIndex )
- break;
- case 'fast-forward':
- // cv.moveToLastPage();
- break;
- }
- //更新分页文本
- display.innerHTML = ( pageIndex + 1 ) + ' / ' + ( pageCount );
- // 确定哪些分页按钮启用/禁用
- enableBackwards = pageIndex <= 0;
- enableForwards = pageIndex >= pageCount - 1;
- // 启用/禁用分页按钮
- fb.disabled = enableBackwards;
- sb.disabled = enableBackwards;
- sf.disabled = enableForwards;
- ff.disabled = enableForwards;
- }
- // initialize the grid
- var grid = new wijmo.grid.FlexGrid( '#theGrid', {
- autoGenerateColumns: false, //自定义显示表头名
- columns: [ {
- binding: 'Number',
- header: '序号',
- width: "*"
- }, {
- binding: 'Code',
- header: '编码',
- width: "*"
- }, {
- binding: 'Name',
- header: '名称',
- width: "*"
- }, ],
- itemsSource: cv,
- selectionMode: wijmo.grid.SelectionMode.Row
- } );
- } );
复制代码
我自定了总页数 和 当前页,这样的话这个控件的分页方法都没用了。得我自己处理吧 |