This is a migrated thread and some comments may be shown as answers.

Coloring all cells in a specific Column

3 Answers 54 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
hamish
Top achievements
Rank 1
hamish asked on 22 May 2014, 09:59 PM
I want to be able to make ALL cells in specific columns a certain background color. I know I can do this using a custom cell template but the problem is that this is extremely slow as it looks at every single cell and then decides what template to apply. It significantly slowed down the performance even with a grid of only several hundred visible columns. I am wondering whether there is a way to just set an entire column to a specific Background and/or foreground color

Thank you



3 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 23 May 2014, 09:56 AM
Hi Hamish,

Using the CellTemplateSelector is the only solution for the desired scenario. What I can suggest you would be to optimize the applied DataTemplates - avoid using StackPanel inside of them, you can replace it with Grid. Also make sure that the PivotGrid itself is not placed inside of StackPanel (use Grid instead) as the StackPanel measures with infinity and this breaks the virtualization - all of the cell containers will be generated at once. 

Hope this will help you to optimize the performance.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
hamish
Top achievements
Rank 1
answered on 23 May 2014, 01:31 PM
Thank you for your reply. The following XAML is the cell template that I am applying to cells in selected columns which is causing the slowness. Can you see what I can do to this data template to make it a lot quicker. For example should the grid and text block be fixed widths and heights etc. I would appreciate your help - thanks
<local:CellTemplateSelector.LightYellowTemplate>
                <DataTemplate>
                    <Border BorderThickness="1 1 0 0" BorderBrush="LightGray">
                        <Grid Background="LightGoldenrodYellow">
                            <TextBlock Text="{Binding Data,Mode=OneWay}" Margin="4" VerticalAlignment="Center" HorizontalAlignment="Right"/>
                        </Grid>
                    </Border>
                </DataTemplate>
            </local:CellTemplateSelector.LightYellowTemplate>

0
Kalin
Telerik team
answered on 27 May 2014, 08:17 AM
Hello Hamish,

The DataTemplate you are applying looks well - it shouldn't be causing the slowness. What I assume is that the custom CellTemplateSelector might slow the process if there is a heavy logic inside (a few for loops for example). So my suggestion is to modify the selector in order to be as simple as possible and to avoid unnecessary heavy processes inside.

Hope this will help you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
PivotGrid
Asked by
hamish
Top achievements
Rank 1
Answers by
Kalin
Telerik team
hamish
Top achievements
Rank 1
Share this question
or