GridViewToggleRowDetailsColumn IsVisible binding doesn't work?

6 posts, 0 answers
  1. Rob Ainscough
    Rob Ainscough avatar
    172 posts
    Member since:
    Jan 2010

    Posted 06 Dec 2012 Link to this post

    I can't get the IsVisible property to bind to a column (Boolean) of my row details data.

    Is this a known bug or limitation?

    <telerik:RadGridView x:Name="TransactionDetailGridView" Margin="0" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="1" FontSize="10.667" MinHeight="10" MaxHeight="150" Height="Auto" RowHeight="16" Background="Transparent" BorderThickness="0" GridLinesVisibility="None" AreRowDetailsFrozen="True" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" RowIndicatorVisibility="Collapsed" RowDetailsVisibilityMode="Collapsed"  IsReadOnly="True" ShowColumnHeaders="False"  ShowGroupPanel="False"
                         ItemsSource="{Binding TransactionDetails}">
        <telerik:RadGridView.RowStyle>
            <Style TargetType="telerik:GridViewRow">
                <Setter Property="Background" Value="Transparent" />
            </Style>
        </telerik:RadGridView.RowStyle>
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="TransactionID" IsVisible="False" DataMemberBinding="{Binding TransactionID}" />
            <telerik:GridViewDataColumn Header="TransactionID" IsVisible="False" DataMemberBinding="{Binding TransactionDetailID}" />
            <telerik:GridViewDataColumn Header="UnitID" IsVisible="False" DataMemberBinding="{Binding UnitID}" />
            <telerik:GridViewDataColumn Header="Unit" Width="80"  DataMemberBinding="{Binding UnitMask}" />
            <telerik:GridViewDataColumn Header="Description" Width="113" DataMemberBinding="{Binding Description}" />
            <telerik:GridViewDataColumn Header="Info." Width="140" DataMemberBinding="{Binding TransactionExtendedDescription}" />
            <telerik:GridViewDataColumn Header="Amount" Width="60" TextAlignment="Right" DataMemberBinding="{Binding TransactionAmount, StringFormat=\{0:C2\}}" />
            <telerik:GridViewToggleRowDetailsColumn IsVisible="{Binding IsTax}" />
            <telerik:GridViewDataColumn Header="Tax" Width="60" TextAlignment="Right" DataMemberBinding="{Binding TotalTaxDescription}" />
            <telerik:GridViewDataColumn Header="Type" Width="113" DataMemberBinding="{Binding TransactionLinkDescription}" />
        </telerik:RadGridView.Columns>
     
        <!-- Taxes -->
        <telerik:RadGridView.RowDetailsTemplate>
            <DataTemplate>
                <Grid Style="{StaticResource DCRowDetailBackground}">
     
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="120"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="20"/>
                    </Grid.ColumnDefinitions>
     
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
     
                    <telerik:RadGridView x:Name="TransactionDetailGridView" Margin="0" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="1" FontSize="10.667" MinHeight="10" MaxHeight="150" Height="Auto" RowHeight="16" Background="Transparent" BorderThickness="0" GridLinesVisibility="None" AreRowDetailsFrozen="True" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" RowIndicatorVisibility="Collapsed" RowDetailsVisibilityMode="Collapsed"  IsReadOnly="True" ShowColumnHeaders="False"  ShowGroupPanel="False"
                                         ItemsSource="{Binding TransactionDetailTaxes}">
                        <telerik:RadGridView.RowStyle>
                            <Style TargetType="telerik:GridViewRow">
                                <Setter Property="Background" Value="Transparent" />
                            </Style>
                        </telerik:RadGridView.RowStyle>
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn Header="TransactionID" IsVisible="False" DataMemberBinding="{Binding TransactionID}" />
                            <telerik:GridViewDataColumn Header="TransactionID" IsVisible="False" DataMemberBinding="{Binding TransactionDetailID}" />
                            <telerik:GridViewDataColumn Header="UnitID" IsVisible="False" DataMemberBinding="{Binding UnitID}" />
                            <telerik:GridViewDataColumn Header="Description" Width="110" DataMemberBinding="{Binding Description}" />
                            <telerik:GridViewDataColumn Header="Info." Width="110" DataMemberBinding="{Binding TransactionExtendedDescription}" />
                            <telerik:GridViewDataColumn Header="Amount" Width="60" TextAlignment="Right" DataMemberBinding="{Binding TransactionAmount, StringFormat=\{0:C2\}}" />
                            <telerik:GridViewDataColumn Header="Type" Width="110" DataMemberBinding="{Binding TransactionLinkDescription}" />
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>
                     
                </Grid>
            </DataTemplate>
        </telerik:RadGridView.RowDetailsTemplate>    
         
    </telerik:RadGridView>
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 11 Dec 2012 Link to this post

    Hi Rob,

    I am not sure I get you question correctly. If you want to hide the whole column with the binding, you have to explicitly state the source of the binding. If you want to change the visibility of the expander button, you can do that by using a cell style/template selector for the GridViewToggleRowDetailsColumn.

    Hope this helps! 

    Regards,
    Nik
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Rob Ainscough
    Rob Ainscough avatar
    172 posts
    Member since:
    Jan 2010

    Posted 11 Dec 2012 Link to this post

    Hi Nik,

    Let me clarify.  The problem is that I will get the small + button for the GridViewToggleRowDetailsColumn even when there are no row details data.  I want to be able to dynamically hide the + button based on values in the data that populates the gridview. Binding the IsVisible to my data (boolean DataMember) doesn't work.

    Is there some other way to dynamically hide the + button based on data populating the GridView?  (on a row by row basis)

    Thanks, Rob.
  5. Nick
    Admin
    Nick avatar
    593 posts

    Posted 12 Dec 2012 Link to this post

    Hello Rob,

    Thank you for the clarification. 
    Binding to the IsVisible property won't work, since it is responsible for the Column visibility, not its cells content. Furthermore the binding does not work, because the DataContext of the Column is different from the one for its cells, therefore the Binding cannot find its source property. 

    To the question itself. The easiest way to do it, as I already mentioned, is to use a Style/DataTemplateSelector for the Column itself. 
    Another way is to use the Row/CellLoaded events, and temper with the expander button visibility there. 

    Hope this helps! 

    Regards,
    Nik
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Samuel
    Samuel avatar
    1 posts
    Member since:
    Aug 2014

    Posted 16 Oct 2014 Link to this post

    In case anybody is still interested in the solution, the binding has to be changed as follows:

    <telerik:GridViewToggleRowDetailsColumn IsVisible="{Binding DataContext.IsTax, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}" />


  7. Kale
    Kale avatar
    2 posts
    Member since:
    Jul 2014

    Posted 19 Aug in reply to Samuel Link to this post

    Thank you! I was missing the DataContext part of the binding.
Back to Top
DevCraft banner