@@ -272,7 +272,7 @@ export interface IAjaxComponentData extends IComponentData {
272272 *
273273 * $demo = data-encapsulation/ajax-events
274274 *
275- * param callback 回调函数
275+ * @ param callback 回调函数
276276 * @param context 回调函数`callback`执行的上下文
277277 * @returns 返回一个函数,调用它后,`callback`则不会再次被触发。
278278 * 如果你注册了这个回调,则请在组件的`ngOnDestroy()`方法中调用一下这个函数,避免内存泄露。
@@ -636,8 +636,6 @@ export class PagingInfo implements IEmittable {
636636 this . totalRecord = totalRecord ;
637637 }
638638
639- private _currentPage : number = 1 ;
640- private _pageSize : number = 20 ;
641639 private _totalPage : number = 1 ;
642640
643641 /**
@@ -646,6 +644,9 @@ export class PagingInfo implements IEmittable {
646644 */
647645 public totalRecord : number = 0 ;
648646
647+
648+ private _pageSize : number = 20 ;
649+
649650 /**
650651 * 当前单页记录数
651652 *
@@ -658,11 +659,15 @@ export class PagingInfo implements IEmittable {
658659 }
659660
660661 public set pageSize ( value : number ) {
661- if ( isNaN ( value ) || value < 1 ) return ;
662+ if ( isNaN ( value ) || value < 1 || this . autoPageSizing || this . _pageSize === value ) {
663+ return ;
664+ }
662665 this . _pageSize = value ;
663666 this . emit ( ) ;
664667 }
665668
669+ private _currentPage : number = 1 ;
670+
666671 /**
667672 * 当前页索引,从1开始计数。修改此属性后,`PagingInfo`会发出获取对应页数据的事件,通过`subscribe`添加监听器可处理此事件。
668673 *
@@ -691,6 +696,81 @@ export class PagingInfo implements IEmittable {
691696 return this . totalRecord && this . pageSize != Infinity ? Math . ceil ( this . totalRecord / this . pageSize ) : 1 ;
692697 }
693698
699+ private _autoPageSizing : boolean = false ;
700+
701+ /**
702+ * 自动分页
703+ *
704+ * 自动分页的开关,开启时,会依据 `containerHeight` 和 `itemHeight` 参数计算 `pageSize`,
705+ * 注意:在本属性为true时,直接操作`pageSize`无效
706+ */
707+ public get autoPageSizing ( ) : boolean {
708+ return this . _autoPageSizing ;
709+ }
710+
711+ public set autoPageSizing ( value : boolean ) {
712+ if ( this . _autoPageSizing == ! ! value ) {
713+ return ;
714+ }
715+ if ( ! ! value ) {
716+ this . _calcAutoPageSize ( ) ;
717+ }
718+ this . _autoPageSizing = ! ! value ;
719+ this . emit ( ) ;
720+ }
721+
722+ private _containerHeight : number ;
723+
724+ /**
725+ * 本属性用于实现动态分页记录数的功能,它指明了用于显示分页数据的容器总高度,配合 `itemHeight` 属性可计算出当前最佳单页记录数
726+ *
727+ * 如:table组件内容高度
728+ *
729+ * $demo=table/auto-page-sizing
730+ */
731+ public get containerHeight ( ) : number {
732+ return this . _containerHeight ;
733+ }
734+
735+ public set containerHeight ( value : number ) {
736+ if ( isNaN ( value ) || value < 1 ) {
737+ return ;
738+ }
739+ this . _containerHeight = value ;
740+ this . _calcAutoPageSize ( ) ;
741+ this . emit ( ) ;
742+ }
743+
744+ private _itemHeight : number ;
745+
746+ /**
747+ * 本属性用于实现动态分页记录数的功能,它指明了单条记录的高度,配合 `containerHeight` 属性可计算出当前最佳单页记录数
748+ *
749+ * 如:table组件内容高度
750+ *
751+ * $demo=table/auto-page-sizing
752+ */
753+ public get itemHeight ( ) : number {
754+ return this . _itemHeight ;
755+ }
756+
757+ public set itemHeight ( value : number ) {
758+ if ( isNaN ( value ) || value < 1 ) {
759+ return ;
760+ }
761+ this . _itemHeight = value ;
762+ this . _calcAutoPageSize ( ) ;
763+ this . emit ( ) ;
764+ }
765+
766+ private _calcAutoPageSize ( ) : void {
767+ if ( ! this . autoPageSizing || isNaN ( this . containerHeight ) || isNaN ( this . itemHeight ) ) {
768+ return ;
769+ }
770+ const newPageSize = Math . floor ( this . containerHeight / this . itemHeight ) ;
771+ this . _pageSize = newPageSize || 1 ;
772+ }
773+
694774 private _emitter = new EventEmitter < any > ( ) ;
695775
696776 public emit ( value ?: any ) : void {
@@ -726,8 +806,6 @@ export class PagingInfo implements IEmittable {
726806export class DataFilterInfo {
727807 constructor ( /**
728808 * 过滤关键字
729- *
730- *
731809 */
732810 public key : string = '' ,
733811 /**
0 commit comments