Swap rows <-> columns

3 posts, 0 answers
  1. Alexander
    Alexander avatar
    78 posts
    Member since:
    Apr 2013

    Posted 06 May 2015 Link to this post

    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. Alexander
    Alexander avatar
    78 posts
    Member since:
    Apr 2013

    Posted 06 May 2015 in reply to Alexander Link to this post

    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>
  3. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 06 May 2015 Link to this post

    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.

     
Back to Top