Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
Pagination calculation (Result Per page calculation after sorting)

I'm trying to develop pagination, and I'll need to figure out how to limit my result set by item offset. I managed to implement the start, end, and total page count in some way. However, when I sort the product data, the start, end, and total page count values remain the same.

eg.

before sorted -> Showing 1 to 10 of 60 ( 6 pages)

after sorted -> Showing 1 to 10 of 0 ( 0 pages)

const totalProductCount = 60
const resultPerPage = 10
const currentPageNumber = 1
const totalPageCount = Math.round(totalProductCount / resultPerPage)
const from = parseInt((currentPageNumber - 1) * resultPerPage) + 1
const to = parseInt(currentPage * resultPerPage)

console.log(Showing {from} to {to} of {totalProductsCount} ({totalPageCount} Pages))

// Showing 1 to 10 of 60 ( 6 pages)

However, after the data is sorted, the totalProducts count falls to 0, and the result remains the same.

const totalProductCount = 0
const resultPerPage = 10
const currentPageNumber = 1
const totalPageCount = Math.round(totalProductCount / resultPerPage)
const from = parseInt((currentPageNumber - 1) * resultPerPage) + 1
const to = parseInt(currentPage * resultPerPage)

console.log(Showing {from} to {to} of {totalProductsCount} ({totalPageCount} Pages))

// Showing 1 to 10 of 0 ( 0 pages) // still same

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda