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

Swap rows <-> columns

2 Answers 370 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 06 May 2015, 06:26 AM

Hello!

Is it possible in the GridView to swap rows and columns?
I want to display my items (bound to ItemsSource) as different columns, while the rows are fixed (and correspond to the "Columns" of the GridView).

It should look similar to http://blogs.microsoft.co.il/tomershamam/2008/09/22/lthowtogtreplace-listview-columns-with-rowslthowtogt/

However, I would prefer if the style matches our other (telerik) grids.

Alex

2 Answers, 1 is accepted

Sort by
0
Alexander
Top achievements
Rank 1
answered on 06 May 2015, 09:58 AM

I found a solution to achieve what I want:

I create a style with some LayoutTransforms and applied them to the grid and it's cells.

<TransformGroup x:Key="ForwardRotateTransform">
    <RotateTransform Angle="-90" />
    <ScaleTransform ScaleY="-1" />
</TransformGroup>
<TransformGroup x:Key="ReverseRotateTransform">
    <ScaleTransform ScaleY="-1" />
    <RotateTransform Angle="90" />
</TransformGroup>
 
<Style x:Key="RotatedGridStyle" TargetType="telerik:RadGridView" BasedOn="{StaticResource {x:Type telerik:RadGridView}}">
    <Style.Resources>
        <Style TargetType="telerik:GridViewCell" BasedOn="{StaticResource {x:Type telerik:GridViewCell}}">
            <Setter Property="LayoutTransform" Value="{StaticResource ReverseRotateTransform}"/>
        </Style>
        <Style TargetType="telerik:GridViewHeaderCell" BasedOn="{StaticResource {x:Type telerik:GridViewHeaderCell}}">
            <Setter Property="LayoutTransform" Value="{StaticResource ReverseRotateTransform}"/>
        </Style>
    </Style.Resources>
 
    <Setter Property="LayoutTransform" Value="{StaticResource ForwardRotateTransform}" />
    <Setter Property="RowIndicatorVisibility" Value="Collapsed" />
    <Setter Property="CanUserResizeColumns" Value="False" />
    <Setter Property="CanUserResizeRows" Value="False" />
    <Setter Property="CanUserSortColumns" Value="False"/>
</Style>
0
Dimitrina
Telerik team
answered on 06 May 2015, 10:57 AM
Hello,

Thank you for sharing the solution you came up with. RadGridView itself does not suggest such a functionality out-of-the box.

Regards,
Dimitrina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
GridView
Asked by
Alexander
Top achievements
Rank 1
Answers by
Alexander
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or