We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to improve performance when using formatting and styling for the cells based on data?

In SfDataGrid, you can customize the Cell/Row style based on the data in the following three ways,

  1. StyleSelector
  2. DataTriggers
  3. Customizing property in Style using Converters

StyleSelector

You can customize the Cell/Row based on content by using CellStyleSelector/ RowStyleSelector, but it affects the performance while styling more number of columns or rows. Therefore, this is not a recommended way for styling the SfDataGrid for more number of columns or rows. You can use this StyleSelector according to your necessity.

To know more about the StyleSelector you can refer to the following links:

http://help.syncfusion.com/ug/wpf/#!documents/styleselectors.htm

http://www.syncfusion.com/kb/2600

DataTriggers

You can customize the Cell/Row based on content by using Style.Triggers, but compared to Binding Converter, the performance is low when styling more number of columns or rows in SfDataGrid.

To know more about the DataTriggers you can refer to the following links:

http://www.syncfusion.com/kb/2600

Customizing the properties in Style using Converters

In SfDataGrid, customizing properties in Style using Converter is the suggested way to customize the properties of Cell/Row, based on its content. As it provides improved performance compared to other two ways.

For Cell Style

In the following code example, the Background of the GridCell for a particular column is customized based on its content using Converters.

XAML

The following code example illustrates the CellStyleConverter for customizing the Cell style based on the Cell content.

C#

The following screenshot displays the output of CellStyle in SfDataGrid.

F:\Farjana\F Drive\KB\Styles Performance\CellStyle 1.png

Figure 1: CellStyle in SfDataGrid

For Row Style

In the following code example, the Background of the VirtualizingCellsControl is customized based on its content using Converters.

XAML

The following code example illustrates the RowStyleConverter for customizing the Cell/Row style.

C#

The following screenshot displays the output of RowStyle in SfDataGrid.

F:\Farjana\F Drive\KB\Styles Performance\RowStyle1.png

Figure 2: RowStyle in SfDataGrid

Sample Link:

Refer to the following sample links to customize the GridCell, based on the Converter to increase the performance of the SfDataGrid in WPF and Silverlight.

WPF: StylePerformanceofSfDataGrid_WPF

Silverlight: StylePerformanceofSfDataGrid_SilverLight

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework: Product Version:
3177 01/12/2015 07/09/2015 Silverlight SfDataGrid 4.5 12.3.0.36
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon