CxJS

Buffering

import { Grid } from 'cx/widgets'; Copied

Grid supports buffered rendering which dramatically improves performance with large datasets. Instead of rendering all rows, only visible rows plus a buffer are rendered, enabling smooth scrolling with thousands of records.

<div controller={PageController}>
  <Grid
    records={m.records}
    keyField="id"
    buffered
    style="height: 400px"
    mod={["fixed-layout", "contain"]}
    cached
    selection={{ type: KeySelection, bind: m.selection }}
    columns={[
      {
        header: "#",
        align: "center",
        children: <div class="cxe-grid-row-number" />,
        defaultWidth: 70,
      },
      {
        header: { text: "Name", style: "width: 100%" },
        field: "fullName",
        sortable: true,
        resizable: true,
      },
      {
        header: "Continent",
        field: "continent",
        sortable: true,
        resizable: true,
        defaultWidth: 130,
      },
      {
        header: "Browser",
        field: "browser",
        sortable: true,
        resizable: true,
        defaultWidth: 100,
      },
      {
        header: "Visits",
        field: "visits",
        sortable: true,
        align: "right",
        resizable: true,
        defaultWidth: 70,
      },
    ]}
  />
</div>
#Name
Continent
Browser
Visits
Alice JohnsonNorth AmericaChrome64
Bob SmithEuropeFirefox86
Carol WhiteAsiaSafari13
David BrownSouth AmericaEdge18
Eva GreenAfricaOpera15
Alice JohnsonNorth AmericaChrome52
Bob SmithEuropeFirefox15
Carol WhiteAsiaSafari84
David BrownSouth AmericaEdge4
Eva GreenAfricaOpera39
Alice JohnsonNorth AmericaChrome24
Bob SmithEuropeFirefox87
Carol WhiteAsiaSafari98
David BrownSouth AmericaEdge48
Eva GreenAfricaOpera77
Alice JohnsonNorth AmericaChrome29
Bob SmithEuropeFirefox42
Carol WhiteAsiaSafari42
David BrownSouth AmericaEdge99
Eva GreenAfricaOpera76
Alice JohnsonNorth AmericaChrome28
Bob SmithEuropeFirefox73
Carol WhiteAsiaSafari73
David BrownSouth AmericaEdge78
Eva GreenAfricaOpera12
Alice JohnsonNorth AmericaChrome2
Bob SmithEuropeFirefox14
Carol WhiteAsiaSafari91
David BrownSouth AmericaEdge19
Eva GreenAfricaOpera71
Alice JohnsonNorth AmericaChrome91
Bob SmithEuropeFirefox64
Carol WhiteAsiaSafari34
David BrownSouth AmericaEdge82
Eva GreenAfricaOpera15
Alice JohnsonNorth AmericaChrome24
Bob SmithEuropeFirefox47
Carol WhiteAsiaSafari96
David BrownSouth AmericaEdge77
Eva GreenAfricaOpera95
Alice JohnsonNorth AmericaChrome63
Bob SmithEuropeFirefox41
Carol WhiteAsiaSafari92
David BrownSouth AmericaEdge38
Eva GreenAfricaOpera86
Alice JohnsonNorth AmericaChrome22
Bob SmithEuropeFirefox2
Carol WhiteAsiaSafari73
David BrownSouth AmericaEdge49
Eva GreenAfricaOpera57
Alice JohnsonNorth AmericaChrome37
Bob SmithEuropeFirefox34
Carol WhiteAsiaSafari52
David BrownSouth AmericaEdge60
Eva GreenAfricaOpera65
Alice JohnsonNorth AmericaChrome9
Bob SmithEuropeFirefox2
Carol WhiteAsiaSafari81
David BrownSouth AmericaEdge17
Eva GreenAfricaOpera42

This grid contains 5,000 rows but renders smoothly thanks to buffered mode. Try scrolling and sorting to see the performance.

How It Works

Enable buffered mode by setting the buffered property. The grid calculates which rows are visible and renders only those plus a configurable buffer for smooth scrolling.

<Grid
  records={m.records}
  buffered
  style="height: 400px"
  mod={["fixed-layout", "contain"]}
  cached
  columns={columns}
/>

For optimal performance, combine buffering with:

  • Fixed height - The grid needs a fixed height to calculate visible rows
  • mod="fixed-layout" - Uses CSS table-layout: fixed for faster rendering
  • mod="contain" - Adds CSS containment for better browser optimization
  • cached - Prevents row re-renders when unrelated store data changes

Row Numbers

Use the built-in cxe-grid-row-number class to display automatic row numbers:

{
  header: "#",
  defaultWidth: 50,
  children: <div class="cxe-grid-row-number" />
}

Configuration

PropertyTypeDescription
bufferedbooleanEnables buffered rendering mode.
bufferSizenumberNumber of rows to render outside the visible area. Default is 60.
bufferStepnumberNumber of rows to add/remove when scrolling. Default is 15.
cachedbooleanPrevents row re-renders when unrelated store data changes. Rows only update when their record data changes.
lockColumnWidthsbooleanLocks column widths to prevent layout shifts during scrolling.
lockColumnWidthsRequiredRowCountnumberMinimum number of rows required before column widths are locked.
measureRowsOnScrollbooleanRe-measures row heights while scrolling. Useful for variable height rows.

See also: Infinite Scrolling