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

MergedCellsStyle Problem

4 Answers 213 Views
GridView
This is a migrated thread and some comments may be shown as answers.
guo
Top achievements
Rank 1
guo asked on 05 Mar 2020, 09:39 AM

Hello,

MergedCellsStyle of my RadGridView is below.I want to chenge the background of the mergedCell when it is selected.But the code dose not work.

How to achieve that?

Thanks.

<Style x:Key="GridViewMergedCell1" TargetType="telerik:GridViewMergedCell" >
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding}" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold"/>
                        </StackPanel>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Background" Value="AliceBlue"/>
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="AliceBlue"/>
                </Trigger>
            </Style.Triggers>
        </Style>

4 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 09 Mar 2020, 12:24 PM

Hello Guo, 

Thank you for the provided code snippet. 

Currently the merged cells of the RadGridView do not support selection. That said, you can change the visual style of the GridViewMergedCell when it is the CurrentCell. In order to that, you can extract and modify the ControlTemplate of the GridViewMergedCell for the theme that you are using. 

I am attaching a sample project to demonstrate the above mentioned approach. Note, that it uses implicit styling along with the NoXaml dlls, which is the recommended approach for modifying ControlTemplates.

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
guo
Top achievements
Rank 1
answered on 17 Mar 2020, 03:07 AM
Thanks for your reply.It's helpful.
0
guo
Top achievements
Rank 1
answered on 17 Mar 2020, 06:20 AM

There is another problem.

In Cell SelectionUnit, how to change the background of the mergedCell when I select a cell in the same row?

For example, "Hanna" should change the background when  "28" is selected.

0
Vladimir Stoyanov
Telerik team
answered on 19 Mar 2020, 02:45 PM

Hello Guo,

Thank you for the provided picture. 

I am afraid that the described requirement cannot be achieved out-of-the-box. The merged cells are actually drawn on top of the GridViewRows. In the provided picture the merged cell with value "Hanna" is over 2 rows in the RadGridView. Each row represents one data item, however the merged cells do not have a connection to the underlying data items, since they can cover multiple rows. With this in mind, it is difficult to notify the merged cell for the selection of a cell in an underlying row. 

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
guo
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
guo
Top achievements
Rank 1
Share this question
or