获取支持angular2 table 分页排序的公用类
2020-03-26 08:18
1041 查看
- 为了获取和table属性匹配的数据类型,支持分页,跳转的公用类
import {AppComponentBase} from './app-component-base'; import {Injector, OnInit} from '@angular/core'; export class PagedResultDto { items: any[]; totalCount: number; } export class EntityDto { id: number; } export class PagedRequestDto { skipCount: number; maxResultCount: number; } export abstract class PagedListingComponentBase<EntityDto> extends AppComponentBase implements OnInit { public pageSize = 10; public pageNumber = 1; public totalPages = 1; public totalItems: number; public isTableLoading = false; public isQuery = false; public filterText = ""; sortKey = null; sortValue = null; protected constructor(injector: Injector) { super(injector); } ngOnInit(): void { this.refresh(); } sort(sort: {key: string, value: string }) { this.sortKey = sort.key; this.sortValue = sort.value; this.refresh(); } refresh(): void { this.getDataPage(this.pageNumber, this.isQuery); } queryRefresh(): void { this.isQuery = true; this.pageNumber = 1; this.getDataPage(this.pageNumber, this.isQuery); this.isQuery = false; } public getSort(): string { let sorting = ''; if (this.sortKey) { sorting = this.sortKey; if (this.sortValue === 'descend') { sorting += ' DESC'; } else { sorting += ' ASC'; } } return sorting; } public showPaging(result: PagedResultDto, pageNumber: number): void { this.totalPages = ((result.totalCount - (result.totalCount % this.pageSize)) / this.pageSize) + 1; this.totalItems = result.totalCount; } public getDataPage(page: number, isQuery: boolean): void { let req = new PagedRequestDto(); req.maxResultCount = this.pageSize; if(isQuery) { req.skipCount = 0; } else { req.skipCount = (page - 1) * this.pageSize; } if (req.skipCount < 0) { req.skipCount = 0; } this.isTableLoading = true; this.list(req, page, () => { this.isTableLoading = false; }); } protected abstract list(request: PagedRequestDto, pageNumber: number, finishedCallback: Function): void; protected abstract delete(entity: EntityDto): void; }
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- JS实现table表格数据排序(可支持动态数据+分页效果)
- 基于Metronic的Bootstrap开发框架经验总结(18)-- 在代码生成工具Database2Sharp中集成对Bootstrap-table插件的分页及排序支持
- JS实现table表格数据排序功能(可支持动态数据+分页效果)
- bootstrap table使用:前端分页,获取值栈中的json值,加载到table中,获取选中的行信息
- 数据库分页存储过程,支持多字段排序
- ajax获取数据自动创建分页,支持自定义显示数据量以及分页数量
- ASP.Net MVC+Data Table实现分页+排序功能的方法
- table 上移 下移 保存时 获取每行中的值 将排序记录保存到数据库
- 支持定位当前页,自定义排序的分页SQL(拒绝动态SQL)
- 功能不错的分页存储过程,可支持多表查询,任意排序
- 功能不错的分页存储过程/可支持多表查询/任意排序
- 实用强大的分页存储过程 支持多字段排序(保证唯一性)
- 基于BootStrap,不支持AJAX只支持表单提交的分页查询与排序组件
- 使用插件bootstrap-table实现表格记录的查询、分页、排序等处理
- 获取用户star的所有项目信息(支持分页和关键字检索)
- bootstrap table 后台分页时, 后台传字段排序
- 专用于SqlServer2005的高效分页存储过程(支持多字段任意排序,不要求排序字段唯一)
- 高效多表分页存储过程,可支持多表查询,任意排序
- 不错的分页存储过程(支持多表查询任意排序).txt
- 功能不错的分页存储过程,可支持多表查询,任意排序