gridcn2.0.0
Server and data examples

Large data example

Scroll 100,000 rows that are fully loaded in the browser, with an optional FPS meter, and see how little the grid mounts.

This grid holds all 100,000 rows in memory. It needs no server, no scroll mode, and no pagination. The grid mounts only the rows near the viewport, so the number of rows does not set the number of DOM rows. At 420 px and the default row height of 36 px, the grid mounts about 11 rows plus the overscan rows.

Name
Email
Age
Active
Role
Joined
Score
Silent Tiger
user0@example.com
63
Viewer
2023-07-05
4
Quick Lion
user1@example.com
67
Viewer
2021-04-03
89
Swift Wolf
user2@example.com
40
Manager
2020-10-27
80
Eager Lion
user3@example.com
50
User
2022-10-08
51
Eager Tiger
user4@example.com
45
Viewer
2024-10-07
83
Silent Wolf
user5@example.com
24
User
2020-06-01
15
Swift Lion
user6@example.com
34
Viewer
2022-10-18
62
Eager Lion
user7@example.com
21
Manager
2021-10-07
42
Eager Eagle
user8@example.com
25
Editor
2024-06-11
35
Bold Tiger
user9@example.com
19
Editor
2024-03-20
52
Bold Bear
user10@example.com
42
User
2020-04-16
28
Swift Wolf
user11@example.com
47
Manager
2022-08-04
9
Swift Bear
user12@example.com
41
Viewer
2024-05-04
45
Eager Wolf
user13@example.com
35
Editor
2020-02-16
44
Swift Eagle
user14@example.com
65
Viewer
2023-07-13
51
Quick Lion
user15@example.com
22
Manager
2023-03-20
28
Bold Wolf
user16@example.com
30
Editor
2023-08-07
76
Swift Eagle
user17@example.com
19
Admin
2022-03-22
26
Eager Eagle
user18@example.com
35
Manager
2020-11-03
70
Eager Bear
user19@example.com
33
Editor
2022-09-21
67
Silent Lion
user20@example.com
48
Manager
2021-01-03
89
Silent Tiger
user21@example.com
62
Manager
2024-01-12
40
Eager Tiger
user22@example.com
51
Manager
2023-08-01
82
Silent Lion
user23@example.com
26
Admin
2020-09-03
16
Bold Eagle
user24@example.com
26
Admin
2024-09-10
38
Bold Lion
user25@example.com
49
Viewer
2022-01-02
3
Quick Tiger
user26@example.com
26
Viewer
2021-02-08
41
Bold Eagle
user27@example.com
50
Editor
2024-02-20
10
Swift Tiger
user28@example.com
55
Editor
2023-12-02
6
Silent Lion
user29@example.com
35
Viewer
2020-04-17
42
pnpm dlx shadcn@latest add @gridcn/data-grid-large-data-demo

Watch the frame rate

This demo loads the same 100,000 rows and adds an FPS readout in the top-left corner. Scroll fast and watch the number.

Scroll through the 100,000 rows and watch the FPS counter (top-left) — only the visible rows are ever mounted.

Row markers
Name
Email
Age
Active
Role
Joined
Score
1
Silent Tiger
user0@example.com
63
Viewer
2023-07-05
4
2
Quick Lion
user1@example.com
67
Viewer
2021-04-03
89
3
Swift Wolf
user2@example.com
40
Manager
2020-10-27
80
4
Eager Lion
user3@example.com
50
User
2022-10-08
51
5
Eager Tiger
user4@example.com
45
Viewer
2024-10-07
83
6
Silent Wolf
user5@example.com
24
User
2020-06-01
15
7
Swift Lion
user6@example.com
34
Viewer
2022-10-18
62
8
Eager Lion
user7@example.com
21
Manager
2021-10-07
42
9
Eager Eagle
user8@example.com
25
Editor
2024-06-11
35
10
Bold Tiger
user9@example.com
19
Editor
2024-03-20
52
11
Bold Bear
user10@example.com
42
User
2020-04-16
28
12
Swift Wolf
user11@example.com
47
Manager
2022-08-04
9
13
Swift Bear
user12@example.com
41
Viewer
2024-05-04
45
14
Eager Wolf
user13@example.com
35
Editor
2020-02-16
44
15
Swift Eagle
user14@example.com
65
Viewer
2023-07-13
51
16
Quick Lion
user15@example.com
22
Manager
2023-03-20
28
17
Bold Wolf
user16@example.com
30
Editor
2023-08-07
76
18
Swift Eagle
user17@example.com
19
Admin
2022-03-22
26
19
Eager Eagle
user18@example.com
35
Manager
2020-11-03
70
20
Eager Bear
user19@example.com
33
Editor
2022-09-21
67
21
Silent Lion
user20@example.com
48
Manager
2021-01-03
89
22
Silent Tiger
user21@example.com
62
Manager
2024-01-12
40
23
Eager Tiger
user22@example.com
51
Manager
2023-08-01
82
24
Silent Lion
user23@example.com
26
Admin
2020-09-03
16
25
Bold Eagle
user24@example.com
26
Admin
2024-09-10
38
26
Bold Lion
user25@example.com
49
Viewer
2022-01-02
3
27
Quick Tiger
user26@example.com
26
Viewer
2021-02-08
41
28
Bold Eagle
user27@example.com
50
Editor
2024-02-20
10
29
Swift Tiger
user28@example.com
55
Editor
2023-12-02
6
30
Silent Lion
user29@example.com
35
Viewer
2020-04-17
42
pnpm dlx shadcn@latest add @gridcn/data-grid-performance-demo

Load the rows

Pass the whole array as defaultData and give the grid a bounded height. Sort, filter, and edits then run on the array in memory:

import { DataGrid, defineColumns } from "@/components/data-grid/data-grid";

type Person = { id: string; name: string; score: number };

const columns = defineColumns<Person>()([
  { id: "name", header: "Name", accessorKey: "name" },
  { id: "score", header: "Score", accessorKey: "score", type: "number" },
]);

const people: Person[] = Array.from({ length: 100_000 }, (_, i) => ({
  id: `row-${i}`,
  name: `Person ${i}`,
  score: i % 100,
}));

export function BigGrid() {
  return (
    <DataGrid
      defaultData={people}
      columns={columns}
      getRowId={(row) => row.id}
      className="h-96"
    />
  );
}

Without a bounded height, the grid mounts at most 200 rows and warns once in development.

When the rows do not fit in the browser

If the result is too large to load, fetch it in blocks with scroll mode or by page with server pagination.

On this page