File

projects/k-components/src/lib/components/datapager/datapager.component.ts

Metadata

selector wm-data-pager-helper
templateUrl ./datapager.component.html

Index

Properties
Methods
Inputs
Accessors

Constructor

constructor()

Inputs

pageSize
Type : number
Default value : 5
source

Methods

filterCollectionIfRequired
filterCollectionIfRequired(skip: number)
Parameters :
Name Type Optional
skip number No
Returns : void
ngOnInit
ngOnInit()
Returns : void
pageChange
pageChange(pageChangeEvent: PageChangeEvent)
Parameters :
Name Type Optional
pageChangeEvent PageChangeEvent No
Returns : void

Properties

Public outputCollection
Type : GridDataResult
Default value : { data: [], total: 0 }
pageSize
Type : number
Default value : 5
Decorators :
@Input()
Public skip
Type : number
Default value : 0
Public sourceChanged
Type : function
Private sourceCollection
Type : Array<any>

Accessors

source
setsource(value: Array)
Parameters :
Name Type Optional
value Array<any> No
Returns : void
import { Component, Input } from '@angular/core';
import { GridDataResult, PageChangeEvent } from '@progress/kendo-angular-grid';

@Component({
  selector: 'wm-data-pager-helper',
  templateUrl: './datapager.component.html',
})
export class DataPagerHelper {
  private sourceCollection: Array<any>;
  @Input() pageSize = 5;
  @Input()
  set source(value: Array<any>) {
    this.sourceCollection = value;
    this.filterCollectionIfRequired(0);
    if (this.sourceChanged) {
      this.sourceChanged();
    }
  }

  public skip = 0;

  public outputCollection: GridDataResult = { data: [], total: 0 };

  public sourceChanged: () => void;

  constructor() {}

  ngOnInit(): void {
    this.filterCollectionIfRequired(0);
  }

  filterCollectionIfRequired(skip: number): void {
    this.skip = skip;
    if (this.sourceCollection && this.sourceCollection.length > 0) {
      this.outputCollection = {
        data: this.sourceCollection.slice(skip, skip + this.pageSize),
        total: this.sourceCollection.length,
      };
    } else if (this.sourceCollection && this.sourceCollection.length === 0) {
      this.outputCollection = {
        data: [],
        total: 0,
      };
    }
  }

  pageChange(pageChangeEvent: PageChangeEvent): void {
    this.filterCollectionIfRequired(pageChangeEvent.skip);
  }
}
<span></span>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""