Skip to content

Virtual Scrolling ​

Virtual scrolling renders only visible rows, providing smooth performance even with thousands of rows.

Small Dataset (1,000 rows)

Virtual scrolling with 1,000 rows. Only visible rows are rendered for optimal performance. Scroll through the data to see smooth performance.

ID
Name
Price
Category
1
Product 1
$640.46
Electronics
2
Product 2
$930.51
Clothing
3
Product 3
$622.58
Accessories
4
Product 4
$7.64
Electronics
5
Product 5
$92.44
Clothing
6
Product 6
$731.38
Accessories
7
Product 7
$380.43
Electronics
8
Product 8
$25.99
Clothing
9
Product 9
$988.78
Accessories
10
Product 10
$846.46
Electronics
11
Product 11
$387.53
Clothing
12
Product 12
$960.95
Accessories
13
Product 13
$225.19
Electronics
14
Product 14
$505.41
Clothing

Large Dataset (10,000 rows)

Virtual scrolling with 10,000 rows. Even with a large dataset, performance remains smooth. Try sorting and filtering to see how virtual scrolling handles operations efficiently.

ID
Name
Price
Category
Stock
Supplier
1
Product 1
$285.55
Electronics
424
Supplier A
2
Product 2
$741.91
Clothing
168
Supplier B
3
Product 3
$567.52
Accessories
299
Supplier C
4
Product 4
$302.14
Electronics
69
Supplier A
5
Product 5
$392.21
Clothing
229
Supplier B
6
Product 6
$758.88
Accessories
44
Supplier C
7
Product 7
$719.14
Electronics
830
Supplier A
8
Product 8
$450.13
Clothing
567
Supplier B
9
Product 9
$725.16
Accessories
569
Supplier C
10
Product 10
$214.73
Electronics
45
Supplier A
11
Product 11
$132.79
Clothing
580
Supplier B
12
Product 12
$314.48
Accessories
930
Supplier C
13
Product 13
$15.16
Electronics
615
Supplier A
14
Product 14
$449.48
Clothing
193
Supplier B

Virtual Scrolling with Sorting and Filtering

Virtual scrolling works seamlessly with sorting and filtering. Operations are performed on the full dataset, but only visible rows are rendered.

ID
Name
Price
Category
1
Product 1
$640.46
Electronics
2
Product 2
$930.51
Clothing
3
Product 3
$622.58
Accessories
4
Product 4
$7.64
Electronics
5
Product 5
$92.44
Clothing
6
Product 6
$731.38
Accessories
7
Product 7
$380.43
Electronics
8
Product 8
$25.99
Clothing
9
Product 9
$988.78
Accessories
10
Product 10
$846.46
Electronics
11
Product 11
$387.53
Clothing
12
Product 12
$960.95
Accessories
13
Product 13
$225.19
Electronics
14
Product 14
$505.41
Clothing

Basic Virtual Scrolling ​

Virtual scrolling with 5,000 rows. Only visible rows are rendered for optimal performance. Scroll through the data to see smooth performance.

ID
Name
Price
Category
1
Product 1
$476.15
Electronics
2
Product 2
$762.77
Clothing
3
Product 3
$466.01
Accessories
4
Product 4
$755.17
Electronics
5
Product 5
$356.27
Clothing
6
Product 6
$398.42
Accessories
7
Product 7
$817.51
Electronics
8
Product 8
$117.31
Clothing
9
Product 9
$273.23
Accessories
10
Product 10
$601.54
Electronics
11
Product 11
$192.63
Clothing
12
Product 12
$635.92
Accessories
13
Product 13
$458.90
Electronics
14
Product 14
$350.81
Clothing

Code ​

vue
<script setup lang="ts">
import { ref } from 'vue'
import { PantanalGrid, type ColumnDef } from '@pantanal/grid'

const rows = ref(Array.from({ length: 5000 }, (_, i) => ({
  id: i + 1,
  name: `Product ${i + 1}`,
  price: Math.round(Math.random() * 100000) / 100,
  category: ['Electronics', 'Clothing', 'Accessories'][i % 3]
})))

const columns: ColumnDef[] = [
  { field: 'id', title: 'ID', width: 80, sortable: true },
  { field: 'name', title: 'Name', sortable: true, filterable: true },
  { field: 'price', title: 'Price', sortable: true, format: (v: number) => `$${v.toFixed(2)}` },
  { field: 'category', title: 'Category', filterable: true }
]
</script>

<template>
  <PantanalGrid
    :rows="rows"
    :columns="columns"
    key-field="id"
    :virtual="true"
    :height="420"
    :row-height="44"
    locale="en"
    responsive="table"
  />
</template>

How Virtual Scrolling Works ​

Virtual scrolling only renders the rows that are currently visible in the viewport, plus a small buffer above and below. This dramatically improves performance for large datasets.

Benefits ​

  • Performance: Smooth scrolling even with 10,000+ rows
  • Memory efficient: Only visible DOM elements are created
  • Fast initial render: Grid appears instantly regardless of data size
  • Works with all features: Sorting, filtering, and grouping work seamlessly

Configuration ​

Row Height ​

Set a fixed row height for optimal performance:

vue
<PantanalGrid
  :rows="rows"
  :columns="columns"
  key-field="id"
  :virtual="true"
  :row-height="44"
  :height="400"
/>

Dynamic Row Height ​

For variable row heights, omit row-height (performance may be slightly reduced):

vue
<PantanalGrid
  :rows="rows"
  :columns="columns"
  key-field="id"
  :virtual="true"
  :height="400"
/>

When to Use Virtual Scrolling ​

  • ✅ Large datasets: 1,000+ rows
  • ✅ Performance critical: Need smooth scrolling
  • ✅ Memory constrained: Limited device memory
  • ❌ Small datasets: < 100 rows (overhead not worth it)
  • ❌ Variable row heights: May cause layout shifts

Performance Tips ​

  1. Set row height: Fixed height improves performance
  2. Limit columns: Fewer columns = faster rendering
  3. Avoid complex templates: Simple cell templates perform better
  4. Use server-side: For very large datasets, combine with server-side mode

See Also ​