{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "grid-virtual-scrolling",
  "framework": "react",
  "type": "registry:component",
  "component": "Grid",
  "variant": "virtual-scrolling",
  "dependencies": [
    "@syncfusion/ej2-react-grids",
    "@syncfusion/ej2-react-buttons",
    "@syncfusion/ej2-react-inputs"
  ],
  "description": "Data grid virtualizes large order data and supports seamless scrolling and cell editing.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/react/llms.txt",
    "skillPack": "syncfusion/react-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/react/ts/grid-virtual-scrolling.md"
  },
  "files": [
    {
      "target": "src/components/grid-virtual-scrolling/Grid.tsx",
      "content": "/* eslint-disable react-hooks/immutability, @typescript-eslint/no-this-alias */\nimport { GridComponent, ColumnsDirective, ColumnDirective, Inject, VirtualScroll, Edit, Toolbar, type LoadEventArgs } from '@syncfusion/ej2-react-grids';\nimport { ButtonComponent } from '@syncfusion/ej2-react-buttons';\nimport { RatingComponent } from '@syncfusion/ej2-react-inputs';\nimport {\n    names,\n    products,\n    categories,\n    paymentMethods,\n    orderStatuses,\n    priorities,\n    cities,\n    states,\n    countries,\n    warehouses,\n    productToCategory,\n    streetTypes\n} from '../datasource/grid-data';\n\nlet virtualOrderData: Object[] = []; // populated by createVirtualOrderData()\nfunction createVirtualOrderData() {\n    function pmRandom(seed: number) {\n        let t = (seed % 2147483647);\n        if (t <= 0)\n            t += 2147483646;\n        return function () {\n            t = (t * 16807) % 2147483647;\n            return (t - 1) / 2147483646;\n        };\n    }\n    const seed = 123456789;\n    const rand = pmRandom(seed);\n    function randInt(min: number, max: number) {\n        return Math.floor(rand() * (max - min + 1)) + min;\n    }\n    function randChoice(arr: any[]) {\n        return arr[Math.floor(rand() * arr.length)];\n    }\n    function pickAvoidTriplet(arr: any[], fieldName: string) {\n        let v = randChoice(arr);\n        if (virtualOrderData.length >= 2) {\n            const prevItems = virtualOrderData;\n            const a = prevItems[virtualOrderData.length - 1][fieldName as keyof Object];\n            const b = prevItems[virtualOrderData.length - 2][fieldName as keyof Object];\n            if (a === b && a === v) {\n                const alt = arr.filter((s: any) => s !== v);\n                if (alt.length > 0) {\n                    v = randChoice(alt);\n                }\n            }\n        }\n        return v;\n    }\n    function computeAmounts(qty: number, unitPrice: number, discountPct: number, taxPct: number, shippingFee: number) {\n        const gross = qty * unitPrice;\n        const discount = gross * (discountPct / 100);\n        const subtotal = gross - discount;\n        const tax = subtotal * (taxPct / 100);\n        const total = subtotal + tax + shippingFee;\n        return {\n            subtotal: Math.round(subtotal * 100) / 100,\n            taxAmount: Math.round(tax * 100) / 100,\n            totalAmount: Math.round(total * 100) / 100\n        };\n    }\n    const baseTime = new Date(2025, 0, 1).getTime();\n    for (let i = 1; i <= 100000; i++) {\n        const qty = randInt(1, 10);\n        const unitPrice = Math.round((rand() * 500 + 5) * 100) / 100;\n        const discountPct = randInt(0, 20);\n        const taxPct = randInt(0, 18);\n        const shippingFee = Math.round((rand() * 20) * 100) / 100;\n        const amounts = computeAmounts(qty, unitPrice, discountPct, taxPct, shippingFee);\n        const orderDate = new Date(baseTime - randInt(0, 90) * 24 * 3600 * 1000);\n        const shippedDate = new Date(orderDate.getTime() + randInt(1, 14) * 24 * 3600 * 1000);\n        const customerId = randInt(1000, 9999);\n        const custName = randChoice(names);\n        const email = custName.toLowerCase().replace(/\\s+/g, '.') + '@example.com';\n        const paymentMethod = pickAvoidTriplet(paymentMethods, 'PaymentMethod');\n        const rating = randInt(1, 5);\n        const orderStatusVal = pickAvoidTriplet(orderStatuses, 'OrderStatus');\n        const priorityVal = pickAvoidTriplet(priorities, 'Priority');\n        const productName = randChoice(products);\n        const warehouse = randChoice(warehouses);\n        const inventoryCount = randInt(0, 500);\n        let paymentStatus = 'Pending';\n        if (orderStatusVal === 'Delivered' || orderStatusVal === 'Shipped') {\n            paymentStatus = 'Paid';\n        }\n        else if (orderStatusVal === 'Canceled' || orderStatusVal === 'Returned') {\n            if (rating <= 1) {\n                paymentStatus = 'Failed';\n            }\n            else {\n                paymentStatus = (paymentMethod === 'Cash') ? 'Pending' : 'Refunded'; // assuming 'Cash' ≈ COD\n            }\n        }\n        else if (orderStatusVal === 'Packed') {\n            paymentStatus = (paymentMethod === 'Cash') ? 'Pending' : 'Paid';\n        }\n        else if (orderStatusVal === 'Ordered' || orderStatusVal === 'Processing') {\n            paymentStatus = 'Pending';\n        }\n        virtualOrderData.push({\n            OrderID: `ORD-${1000 + i}`,\n            OrderDate: orderDate,\n            ShipDate: shippedDate,\n            CustomerID: `CUS-${customerId}`,\n            CustomerName: custName,\n            Email: email,\n            Phone: `+1-${randInt(200, 999)}-${randInt(1000, 9999)}`,\n            ShipAddress: `${randInt(10, 999)} ${randChoice(streetTypes)}`,\n            ShipCity: randChoice(cities),\n            ShipState: randChoice(states),\n            ShipPostalCode: String(randInt(10000, 99999)),\n            ShipCountry: randChoice(countries),\n            ProductID: `PROD-${randInt(10000, 99999)}`,\n            ProductName: productName,\n            Category: productToCategory[productName] || randChoice(categories),\n            Quantity: qty,\n            UnitPrice: unitPrice,\n            Discount: discountPct,\n            Tax: taxPct,\n            SubTotal: amounts.subtotal,\n            TaxAmount: amounts.taxAmount,\n            ShipFee: shippingFee,\n            TotalAmount: amounts.totalAmount,\n            PaymentMethod: paymentMethod,\n            PaymentStatus: paymentStatus,\n            Warehouse: warehouse,\n            InventoryCount: inventoryCount,\n            Priority: priorityVal,\n            OrderStatus: orderStatusVal,\n            Rating: rating,\n        });\n    }\n}\n\n// custom code end\nfunction Virtualization() {\n    // custom code start\n    let grid: GridComponent;\n    let date1: number;\n    let date2: number;\n    let flag: boolean = true;\n    let enableVirtualization: boolean = true;\n    let data: Object[] = [];\n    const toolbarOptions: any = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];\n    const editSettings: any = { allowEditing: true, allowDeleting: true, newRowPosition: 'Top' };\n\n    function ratingTemplate(props: any) {\n        return (<div><RatingComponent value={props.Rating} cssClass={'custom-rating'} readOnly={true} /></div>);\n    }\n    function paymentMethodTemplate(props: any) {\n        return (\n            <div className=\"e-payment-info\">\n                <img\n                    src={`src/grid/images/payment/${props.PaymentMethod}.svg`}\n                    alt={props.PaymentMethod}\n                />\n                <span>{props.PaymentMethod}</span>\n            </div>\n        );\n    };\n    function orderStatusTemplate(props: any) {\n        if (props.OrderStatus === \"Delivered\") {\n            return (\n                <div className=\"virtual-statustemp e-deliveredcolor\">\n                    <span className=\"virtual-statustxt e-deliveredcolor\">Delivered</span>\n                </div>\n            );\n        }\n        if (props.OrderStatus === \"Shipped\") {\n            return (\n                <div className=\"virtual-statustemp e-shippedcolor\">\n                    <span className=\"virtual-statustxt e-shippedcolor\">Shipped</span>\n                </div>\n            );\n        }\n        if (props.OrderStatus === \"Packed\") {\n            return (\n                <div className=\"virtual-statustemp e-packedcolor\">\n                    <span className=\"virtual-statustxt e-packedcolor\">Packed</span>\n                </div>\n            );\n        }\n        if (props.OrderStatus === \"Processing\") {\n            return (\n                <div className=\"virtual-statustemp e-processingcolor\">\n                    <span className=\"virtual-statustxt e-processingcolor\">Processing</span>\n                </div>\n            );\n        }\n        if (props.OrderStatus === \"Canceled\") {\n            return (\n                <div className=\"virtual-statustemp e-cancelcolor\">\n                    <span className=\"virtual-statustxt e-cancelcolor\">Canceled</span>\n                </div>\n            );\n        }\n        if (props.OrderStatus === \"Returned\") {\n            return (\n                <div className=\"virtual-statustemp e-returnedcolor\">\n                    <span className=\"virtual-statustxt e-returnedcolor\">Returned</span>\n                </div>\n            );\n        }\n        if (props.OrderStatus === \"Ordered\") {\n            return (\n                <div className=\"virtual-statustemp e-orderedcolor\">\n                    <span className=\"virtual-statustxt e-orderedcolor\">Ordered</span>\n                </div>\n            );\n        }\n    };\n    function priorityTemplate(props: any) {\n        if (props.Priority === \"High\") {\n            return (\n                <div className=\"virtual-statustemp e-highcolor\">\n                    <span className=\"virtual-statustxt e-highcolor\">High</span>\n                </div>\n            );\n        }\n        if (props.Priority === \"Low\") {\n            return (\n                <div className=\"virtual-statustemp e-lowcolor\">\n                    <span className=\"virtual-statustxt e-lowcolor\">Low</span>\n                </div>\n            );\n        }\n        if (props.Priority === \"Medium\") {\n            return (\n                <div className=\"virtual-statustemp e-mediumcolor\">\n                    <span className=\"virtual-statustxt e-mediumcolor\">Medium</span>\n                </div>\n            );\n        }\n        if (props.Priority === \"Critical\") {\n            return (\n                <div className=\"virtual-statustemp e-criticalcolor\">\n                    <span className=\"virtual-statustxt e-criticalcolor\">Critical</span>\n                </div>\n            );\n        }\n    };\n    function paymentStatusTemplate(props: any) {\n        if (props.PaymentStatus === \"Paid\") {\n            return (\n                <div className=\"virtual-statustemp e-paidcolor\">\n                    <span className=\"virtual-statustxt e-paidcolor\">Paid</span>\n                </div>\n            );\n        }\n        if (props.PaymentStatus === \"Pending\") {\n            return (\n                <div className=\"virtual-statustemp e-pendingcolor\">\n                    <span className=\"virtual-statustxt e-pendingcolor\">Pending</span>\n                </div>\n            );\n        }\n        if (props.PaymentStatus === \"Refunded\") {\n            return (\n                <div className=\"virtual-statustemp e-refundcolor\">\n                    <span className=\"virtual-statustxt e-refundcolor\">Refunded</span>\n                </div>\n            );\n        }\n        if (props.PaymentStatus === \"Failed\") {\n            return (\n                <div className=\"virtual-statustemp e-failedcolor\">\n                    <span className=\"virtual-statustxt e-failedcolor\">Failed</span>\n                </div>\n            );\n        }\n    };\n\n    function onclick() {\n        if (!data.length) {\n            show();\n            createVirtualOrderData();\n            date1 = new Date().getTime();\n            grid.dataSource = data = virtualOrderData;\n            grid.editSettings.allowAdding = true;\n        } else {\n            flag = true;\n            show();\n            date1 = new Date().getTime();\n            grid.refresh();\n        }\n    }\n    function show() {\n        document.getElementById('popup')!.style.display = 'inline-block';\n    }\n    function hide() {\n        if (flag && date1) {\n            date2 = new Date().getTime();\n            document.getElementById('performanceTime')!.innerHTML = 'Time Taken: ' + (date2 - date1) + 'ms';\n            flag = false;\n        }\n        document.getElementById('popup')!.style.display = 'none';\n    }\n    function load(args: LoadEventArgs) {\n        if (enableVirtualization) {\n            args.enableSeamlessScrolling = true;\n        }\n    }\n\n    return (\n        <div className='control-pane'>\n            <div className='control-section'>\n                <div className='div-button'>\n                    {/* @ts-ignore */}\n                    <ButtonComponent cssClass={'e-info'} onClick={onclick.bind(this as any)}>Load 100K Data</ButtonComponent>\n                    <span id=\"popup\">\n                        <span id=\"gif\" className=\"imagepop\"></span>\n                    </span>\n                    <span id=\"performanceTime\">Time Taken: 0 ms</span>\n                </div>\n                <GridComponent id=\"VirtualScroll\" dataSource={[]} enableVirtualization={enableVirtualization} clipMode='EllipsisWithTooltip' enableColumnVirtualization={true} height={400}\n                    ref={(g: any) => grid = g} \n                    // @ts-ignore\n                    dataBound={hide.bind(this as any)} \n                    // @ts-ignore\n                    load={load.bind(this as any)} toolbar={toolbarOptions} editSettings={editSettings} rowHeight={50}>\n                    <ColumnsDirective>\n                        <ColumnDirective field=\"OrderID\" headerText=\"Order ID\" width={110} isPrimaryKey={true} validationRules={{ required: true }} />\n                        <ColumnDirective field=\"OrderDate\" headerText=\"Order Date\" width={140} format=\"yMd\" textAlign=\"Right\" editType=\"datepickeredit\" />\n                        <ColumnDirective field=\"ShipDate\" headerText=\"Ship Date\" width={140} format=\"yMd\" textAlign=\"Right\" editType=\"datepickeredit\" />\n                        <ColumnDirective field=\"OrderStatus\" headerText=\"Order Status\" width={140} textAlign=\"Center\" editType=\"dropdownedit\" template={orderStatusTemplate} validationRules={{ required: true }}/>\n                        <ColumnDirective field=\"Priority\" headerText=\"Priority\" width={120} textAlign=\"Center\" editType=\"dropdownedit\" template={priorityTemplate} />\n                        <ColumnDirective field=\"CustomerName\" headerText=\"Customer Name\" width={190} validationRules={{ required: true }} />\n                        <ColumnDirective field=\"CustomerID\" headerText=\"Customer ID\" width={110} visible={false} />\n                        <ColumnDirective field=\"Email\" headerText=\"Email\" width={200} />\n                        <ColumnDirective field=\"Phone\" headerText=\"Phone Number\" width={140} textAlign=\"Right\" />\n                        <ColumnDirective field=\"ShipAddress\" headerText=\"Ship Address\" width={180} />\n                        <ColumnDirective field=\"ShipCity\" headerText=\"Ship City\" width={120} />\n                        <ColumnDirective field=\"ShipState\" headerText=\"Ship State Code\" width={130} />\n                        <ColumnDirective field=\"ShipPostalCode\" headerText=\"Ship Postal Code\" width={130} textAlign=\"Right\" />\n                        <ColumnDirective field=\"ShipCountry\" headerText=\"Ship Country\" width={150} />\n                        <ColumnDirective field=\"ProductName\" headerText=\"Product Name\" width={250} />\n                        <ColumnDirective field=\"ProductID\" headerText=\"Product ID\" width={110} visible={false} />\n                        <ColumnDirective field=\"Category\" headerText=\"Category\" width={120} />\n                        <ColumnDirective field=\"Warehouse\" headerText=\"Ware house\" width={110} editType=\"dropdownedit\" visible={false}/>\n                        <ColumnDirective field=\"InventoryCount\" headerText=\"Inventory Count\" width={150} textAlign=\"Right\" visible={false} />\n                        <ColumnDirective field=\"Quantity\" headerText=\"Quantity\" width={100} textAlign=\"Right\" editType=\"numericedit\" edit={{ params: { showSpinButton: false } }} />\n                        <ColumnDirective field=\"UnitPrice\" headerText=\"Unit Price\" width={110} format=\"C2\" textAlign=\"Right\" editType=\"numericedit\" edit={{ params: { showSpinButton: false } }} />\n                        <ColumnDirective field=\"Discount\" headerText=\"Discount (%)\" width={120} textAlign=\"Right\" editType=\"numericedit\" edit={{ params: { showSpinButton: false } }} />\n                        <ColumnDirective field=\"Tax\" headerText=\"Tax (%)\" width={100} textAlign=\"Right\" editType=\"numericedit\" edit={{ params: { showSpinButton: false } }} />\n                        <ColumnDirective field=\"SubTotal\" headerText=\"Sub Total\" width={110} format=\"C2\" textAlign=\"Right\" editType=\"numericedit\" edit={{ params: { showSpinButton: false } }} />\n                        <ColumnDirective field=\"TaxAmount\" headerText=\"Tax Amount\" width={110} format=\"C2\" textAlign=\"Right\" editType=\"numericedit\" edit={{ params: { showSpinButton: false } }} />\n                        <ColumnDirective field=\"ShipFee\" headerText=\"Ship Fee\" width={120} format=\"C2\" textAlign=\"Right\" editType=\"numericedit\" edit={{ params: { showSpinButton: false } }} />\n                        <ColumnDirective field=\"TotalAmount\" headerText=\"Total Amount\" width={120} format=\"C2\" textAlign=\"Right\" editType=\"numericedit\" edit={{ params: { showSpinButton: false } }} />\n                        <ColumnDirective field=\"PaymentMethod\" headerText=\"Payment Method\" width={140} editType=\"dropdownedit\" template={paymentMethodTemplate} validationRules={{ required: true }}/>\n                        <ColumnDirective field=\"PaymentStatus\" headerText=\"Payment Status\" width={140} textAlign=\"Center\" editType=\"dropdownedit\" template={paymentStatusTemplate} validationRules={{ required: true }}/>\n                        <ColumnDirective field=\"Rating\" headerText=\"Delivery Rating\" width={160} textAlign=\"Center\" visible={false} template={ratingTemplate} editType=\"dropdownedit\" />\n                    </ColumnsDirective>\n                    <Inject services={[VirtualScroll, Toolbar, Edit]} />\n                </GridComponent>\n            </div>\n        </div>\n    )\n}\nexport default Virtualization;"
    }
  ]
}