Data grid example

Edit ten thousand loaded records.

A bounded row window retains the focused editor while the rest of the supplied data scrolls. Pages offer a sequential reading view.

Complete React client module · MIT · Next.js and Vite

Interactive example

Edit ten thousand loaded records

A bounded row window retains the focused editor while the rest of the supplied data scrolls. Pages offer a sequential reading view.

Keyboard

  • Arrow keys and Control or Command+Home/End move through loaded records, including unmounted rows.
  • Enter edits; Escape cancels. Scrolling keeps the current editor mounted at its logical position.
  • Choose Pages for sequential reading. Finish an incomplete editor before switching views.
  • Clipboard and bulk operations still allow at most 100 records and 2,000 cells.

States covered

  • 10000 loaded records
  • row virtualization
  • retained editor
  • logical pinning
  • bounded clipboard
  • paged reading
  • loaded summaries

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-data-grid-virtualized-10000.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import { useCallback, useRef, useState } from 'react';
import { AdvancedDataGrid, Button, parseDataValue, type DataColumn, type DataEdit, type DataGridHandle, type DataSummarySpec } from '@bld8/ui';

type RecordRow={id:string;revision:number;title:string;team:string;hours:number;ready:boolean};
const columns:DataColumn<RecordRow>[]=[
  {key:'id',label:'Record',type:'text',pinned:'start',width:132,hideable:false},
  {key:'title',label:'Title',type:'text',editable:true,width:260,maxLength:120},
  {key:'team',label:'Team',type:'select',editable:true,width:150,options:[{value:'product',label:'Product'},{value:'engineering',label:'Engineering'}]},
  {key:'hours',label:'Hours',type:'number',editable:true,min:0,max:100,width:112},
  {key:'ready',label:'Ready',type:'boolean',editable:true,width:112}
];
const initialRows:RecordRow[]=Array.from({length:10000},(_,index)=>({id:'BIG-'+String(index+1).padStart(5,'0'),revision:1,title:'Review item '+(index+1),team:index%2?'engineering':'product',hours:index%8+1,ready:index%3===0}));
const summaries:DataSummarySpec<RecordRow>[]=[{id:'records',label:'Loaded records',operation:'count'},{id:'hours',label:'Total hours',operation:'sum',key:'hours'},{id:'average',label:'Average hours',operation:'average',key:'hours'}];
export default function VirtualizedRecordsExample(){
  const [rows,setRows]=useState(initialRows),[notice,setNotice]=useState('');
  const navigation=useRef<DataGridHandle|null>(null);
  const edit=useCallback((edits:DataEdit<RecordRow>[])=>{
    const changes=new Map<string,Partial<RecordRow>>();
    for(const change of edits){const column=columns.find(column=>column.key===change.key);if(!column)return;const parsed=parseDataValue(column,change.value);if(parsed.error){setNotice(parsed.error);return;}changes.set(change.id,{...changes.get(change.id),[change.key]:parsed.value});}
    setRows(current=>current.map(row=>changes.has(row.id)?{...row,...changes.get(row.id)}:row));setNotice(edits.length+' cells changed locally. No service write was made.');
  },[]);
  return <div style={{minWidth:0}}>
    <Button size="sm" variant="secondary" onClick={()=>{if(!navigation.current?.focusCell('BIG-10000','title'))setNotice('Use Scroll and finish the current editor before jumping.');}}>Focus the last record</Button>
    <AdvancedDataGrid label="Ten thousand editable records" rows={rows} columns={columns} onEdit={edit} navigationRef={navigation} height={400} rowHeight={64} layoutControls resizableColumns bulkEditing summaries={summaries}/>
    <p className="bui-hint">10,000 authored records are already loaded. Only a row window and up to three focused/editor rows stay mounted. Columns remain bounded to 30; this is row virtualization, not an infinite service loader.</p>
    <p role="status">{notice}</p>
  </div>;
}