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

GridViewToggleRowDetailsColumn IsVisible binding doesn't work?

5 Answers 400 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rob Ainscough
Top achievements
Rank 1
Rob Ainscough asked on 06 Dec 2012, 05:20 PM
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>

5 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 11 Dec 2012, 01:05 PM
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.

0
Rob Ainscough
Top achievements
Rank 1
answered on 11 Dec 2012, 09:25 PM
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.
0
Nick
Telerik team
answered on 12 Dec 2012, 10:21 AM
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.

1
Samuel
Top achievements
Rank 1
answered on 16 Oct 2014, 11:43 AM
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}}" />


0
Kale
Top achievements
Rank 1
answered on 19 Aug 2016, 01:26 PM
Thank you! I was missing the DataContext part of the binding.
Tags
GridView
Asked by
Rob Ainscough
Top achievements
Rank 1
Answers by
Nick
Telerik team
Rob Ainscough
Top achievements
Rank 1
Samuel
Top achievements
Rank 1
Kale
Top achievements
Rank 1
Share this question
or