Advertisement
jarturon55

joe

Sep 6th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  addFirstLastPage() {
  2.     setTimeout(() => {
  3.       // add first/last page
  4.       const firstPage = document.createElement("i")
  5.       firstPage.classList.add('material-icons')
  6.       firstPage.style.cursor = 'pointer'
  7.       firstPage.innerHTML = 'first_page'
  8.       firstPage.setAttribute('matTooltip', 'First page')
  9.       const lastPage = document.createElement("i")
  10.       lastPage.classList.add('material-icons')
  11.       lastPage.innerHTML = 'last_page'
  12.       lastPage.style.cursor = 'pointer'
  13.       const pageContainer = document.getElementsByClassName('mat-paginator-range-actions')[0];
  14.       const previousBtn = document.getElementsByClassName('mat-paginator-navigation-previous')[0];
  15.       firstPage.addEventListener('click', () => {
  16.         this.page = 0
  17.         if (this.selectedType == 0) {
  18.           this.getAsvResult(this.size, this.page)
  19.         }
  20.         else {
  21.           this.data = [...this.virtualData.slice(0, this.size)]
  22.         }
  23.       })
  24.       lastPage.addEventListener('click', () => {
  25.         this.page = Math.ceil(this.total / this.size - 1)
  26.         if (this.selectedType == 0) {
  27.           this.getAsvResult(this.size, this.page)
  28.         }
  29.         else {
  30.           this.data = [...this.virtualData.slice(this.size * (this.page + 1) - (this.size),
  31.             this.size * (this.page + 1))]
  32.         }
  33.       })
  34.       pageContainer.insertBefore(firstPage, previousBtn)
  35.       pageContainer.appendChild(lastPage)
  36.     }, 0);
  37.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement