Skip to content

ES-969380-TemplateRenderMode - Provide the UG documentation for TemplateRenderMode Property. #1872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions wpf/DataGrid/Record-Template-View.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,30 @@ Arranges template for the <code>ViewPortHeight</code> when the {{'[RowTemplate](
</tr>
</table>

## Handling Row Virtualization in RowTemplate
By default, rows in the `DataGrid` are virtualized and reused to enhance performance. However, when using a RowTemplate that includes interactive controls (such as SfDataGrid, DataGrid, or similar components), this reuse can lead to unexpected behavior during data operations like sorting or filtering. Specifically, the visual state and data bindings of these controls may not persist correctly.

This occurs because the same row visual elements are recycled and displayed for different data items during virtualization.

To provide greater flexibility, the `TemplateRenderMode` property is available for row templates. This property allows you to configure how the row templates are instantiated and managed within the DataGrid.

## TemplateRenderMode:

### Shared (Default):
* Rows (and their templates) are reused across multiple rows as you scroll or interact with the grid.
* This mode provides the best performance and lowest memory usage.
* Since templates are shared, visual state and control data may not persist correctly during operations like expanding, collapsing, or scrolling. This can lead to visual inconsistencies or data mismatches.

### Individual:
* A unique rows and template instance is created for each data row.
* Template instances are not shared or reused across rows.
* Data operations and visual state are always preserved correctly for each row, even after expanding, collapsing, or scrolling.

N> Use `Shared` for maximum performance and when your row template only contains simple data-bound controls with no per-row persistent state.

Use `Individual` when your row template is contains interactive controls that need to preserve their state for each data row independently.


## Keyboard navigation support for DetailsViewTemplate

In the SfDataGrid, you can navigate from parent row to DetailsViewTemplate and vice-versa using <kbd>Tab</kbd> key by default. You can also restrict tab key navigation from parent to DetailsViewTemplate by setting the [TemplateViewDefinition.TemplateNavigationMode](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.TemplateViewDefinition.html#Syncfusion_UI_Xaml_Grid_TemplateViewDefinition_NavigationMode) property value to `ExcludeTemplateRow`.
Expand Down