# Virtualized Columns

The Telerik Blazor Grid provides Virtual Scrolling for its Columns. This means that columns and the corresponding data will be rendered only for the currently visible viewport. When changing the [Page](https://www.telerik.com/blazor-ui/documentation/components/grid/paging) or [Sorting](https://www.telerik.com/blazor-ui/documentation/components/grid/sorting) the Grid, fewer elements are rendered which improves the responsiveness and the overall user experience.

This article provides the following sections:

* [Basics](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/virtual#basics)
* [Notes](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/virtual#notes)
* [More Examples](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/virtual#more-examples)
  * [Virtualized Columns and Rows](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/virtual#virtualized-columns-and-rows)
  * [Virtualized Autogenerated Columns](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/virtual#virtualized-autogenerated-columns)

## Basics

The targeted scenario is for a Grid with big number of columns, since the performance improvement will be most significant there.

To enable Virtualized Columns:

1. Set the `ColumnVirtualization` parameter of the Grid to `true`.
2. Set the `Width` parameter of all columns in `px` so that the total sum is greater than the `Width` of the Grid.
   * This will enable horizontal scrollbar which is required. You can read more about the scrolling behavior of the grid in the [Grid Column Width Behavior](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/width) article.
3. Set the `RowHeight` so that the content of all cells fits in the row. For more information see the [Notes](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/virtual#notes) section.
4. Set the `Height` of the Grid in `px`. For more information see the [Notes](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/virtual#notes) section.
5. Set the `Width` parameter of the Grid in `px`.

> caption Basic setup of the Virtualized Columns

<demo metaUrl="client/grid/columns-virtual/" height="550"></demo>

> caption The result from the code snippet above - scrolling through the grid is the same as without virtual scrolling, but the rendering performance and responsiveness of all other actions will be improved.

## Notes

* The `RowHeight` must accommodate the height of all the possible cells and their content in order to ensure good appearance. If certain cells that are not rendered have content that is taller than the rendered ones, you may experience glitches and unstable scrolling.
  * If the row/cell height the browser would render is larger than the `RowHeight` value due to the cell contents, the browser will ignore the `RowHeight`. The actual cell height can depend on the chosen Theme or other CSS rules, or on cell data that falls on more than one line. Inspect the rendered HTML to make sure the grid setting matches the rendering.
* The `Height` of the Grid must be explicitly set in `px`. By default the Height is set by the browser depending on the contents. When a new column is rendered during horizontal scrolling, it might increase or decrease the vertical size of the row and cause issues with the rendering and abnormal visual behavior for the users.
* Rendering the Virtual Columns in Client-side Blazor Applications is slower due to the Framework rendering limitations. In the Server-side Applications this issue is not present.

## More Examples

The column virtualization can work together with other similar features in the grid:

* [With Row Virtualization](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/virtual#virtualized-columns-and-rows)
* [With Automatically Generated Columns](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/virtual#virtualized-autogenerated-columns)

### Virtualized Columns and Rows

You can use Virtualized Columns and Rows together. More information on Virtual Rows can be found in the [Virtual Scrolling](https://www.telerik.com/blazor-ui/documentation/components/grid/virtual-scrolling) article.

> caption Use Virtualized Columns and Rows together

<demo metaUrl="client/grid/columns-virtual-rows/" height="550"></demo>

> caption The result from the code snippet above

### Virtualized Autogenerated Columns

Column virtualization is commonly used when you have many columns. You may not have to declare them yourself, the grid can do this for you through its [Automatically Generated Columns](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/auto-generated) feature.

> note In order to add Virtualized Autogenerated Columns, the `ColumnWidth` parameter must be set in pixels.

<demo metaUrl="client/grid/columns-virtual-auto-generated/" height="550"></demo>

> caption The result from the code snippet above

## See Also

* [Live demo: Virtual Columns](https://demos.telerik.com/blazor-ui/grid/column-virtualization)
* [Virtual Scrolling](https://www.telerik.com/blazor-ui/documentation/components/grid/virtual-scrolling)
* [Grid Column Width Behavior](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/width)
* [Automatically Generated Columns](https://www.telerik.com/blazor-ui/documentation/components/grid/columns/auto-generated)
* [Blazor Grid](https://www.telerik.com/blazor-ui/documentation/components/grid/overview)
