簡體   English   中英

如何使用 Material ui 實現服務器端分頁並做出反應?

[英]How to implement a server side pagination with Material ui and react?

目前,您可以使用下一個和上一個選項向后端分頁,但我無法使用每頁行數選項來執行此操作,如何使這兩個選項起作用? 謝謝

這是選項的圖像在此處輸入圖像描述

對於分頁,您需要:

  1. 知道記錄的數量。
  2. 頁面上顯示的記錄數。
  3. 頁碼。

從客戶端發送到服務器: number of records on page數和page number

從服務器發送到客戶端: fromto之間的records

 const count = 20; // for example we have 20 records const size = 7; // there are 7 records on each page // number of pages const countPages = Math.ceil (20/7); //show records on page 2: const page = 2; // display 2nd page const from = (page - 1) * size; const to = Math.min (from + size- 1, count); console.log(`we have ${count} records, ${size} per page` ) console.log('number of pages', countPages); console.log(`on page ${page} records from ${from} to ${to}`);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM