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

Method ExpandAllHierarchyItems() expands GridViewRows with property "IsExpandable" at False ?

4 Answers 302 Views
GridView
This is a migrated thread and some comments may be shown as answers.
TheFlo
Top achievements
Rank 1
TheFlo asked on 08 Mar 2012, 01:28 PM
Hello !

I'm using a custom hierarchy on a RadGridView as defined below :

<telerik:RadGridView x:Name="rgvAttributes" AutoGenerateColumns="False" CanUserDeleteRows="False"
                     IsReadOnlyBinding
="{Binding IsEditAttributesGrid,Mode=TwoWay}"
                    
ItemsSource="{Binding ListEntries}"
                    
SelectedItem="{Binding SelectedAttribute, Mode=TwoWay}" SelectionMode="Single">
    <i:Interaction.Behaviors>
        <helper:IsExpandableBehavior IsExpandableSourcePropertyName="IsExpandable" />
    </i:Interaction.Behaviors>
    <telerik:RadGridView.ChildTableDefinitions>
        <telerik:GridViewTableDefinition />
    </telerik:RadGridView.ChildTableDefinitions>
    <telerik:RadGridView.Columns>
        [...]
    </telerik:RadGridView.Columns>
    <telerik:RadGridView.HierarchyChildTemplate>
        <DataTemplate>
            <Control:ContentStepVisualizer />
        </DataTemplate>
    </telerik:RadGridView.HierarchyChildTemplate>
</telerik:RadGridView>

In order to hide the Expand/Collapse Hierarchy button on several rows, I'm using the following method :
  1. As the name explains, the simple behavior "IsExpandableBehavior" is used to bind the "IsExpandable" property of each GridViewRow to the corresponding object property of the ObservableCollection<Attribute> ListEntries in my ViewModel,
  2. Setting the "IsExpandable" property of one of the Attribute object to False correctly hide the Expand/Collapse Hierarchy button of the corresponding row in the RadGridView.

When calling ExpandAllHierarchyItems() on the RadGridView, every hidden Expand/Collapse Hierarchy buttons appears back and every row expands.

It seems that the ExpandAllHierarchyItems() of RadGridView methods doesn't consider the state of the "IsExpandable" property before expanding a GridViewRow.

Is this the desired behavior or I have done something wrong provoking it ?

Many thanks for your help !

TheFlo

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 12 Mar 2012, 11:02 AM
Hi,

 I have tested how the ExpandAllHierarchyItems() overrides the "IsExpandable" property of the GridViewRow. I was not able to reproduce such a behaviour.

Would it be possible for you to send me a simple running project to show what your behaviour do?

All the best,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
TheFlo
Top achievements
Rank 1
answered on 12 Mar 2012, 01:07 PM
Hi Didie,

Thanks for you reply.

I've opened a support ticket (ID 521701) with a full running project attached.
This project shows two RadGridViews :
  • One using the Behavior "IsExpandableBehavior" to hide the Expand / Collapse button of the GridViewRow
  • One using the event "RowLoaded" to hide the Expand / Collapse button of the GridViewRow using the code given in the Custom Hierarchy Demo example
  • Each RadGridView has a button above to Expand / Collapse all rows.
  • As I click on each button, the GridViews expand all GridViewRows Hierarchy even those who have the property "IsExpandable" to False.

Hope this project will help.

May thanks for your support,

TheFlo

0
Accepted
Dimitrina
Telerik team
answered on 12 Mar 2012, 03:30 PM
Hi,

 Indeed I can confirm that this is a bug into the RadGridView. This issue has been logged into our Public Issue Tracking System under ID 9443

We apologise for the inconvenience caused. 

Regards,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Aaron
Top achievements
Rank 1
answered on 17 Sep 2012, 11:08 PM
It is extremely frustrating that this hasn't yet been resolved.

I'm using the following as a workaround:

private void ReportGrid_RowIsExpandedChanging(object sender, Telerik.Windows.Controls.GridView.RowCancelEventArgs e)
{
    // This is a workaround for "ExpandAllHierarchyItems" issue expanding things that shouldn't be expanded.
    GridViewRow row = e.Row as GridViewRow;
    if (row != null && !row.IsExpandable && !row.IsExpanded)
    {
        e.Cancel = true;
    }
}
 
private void ReportGrid_RowLoaded(object sender, RowLoadedEventArgs e)
{
    // This is a workaround for "ExpandAllHierarchyItems" issue expanding things that shouldn't be expanded.
    GridViewRow row = e.Row as GridViewRow;
    if (row != null && !row.IsExpandable)
    {
        // Force it to re-evaluate the visual state
        Telerik.Windows.Controls.RadGridView grid = sender as Telerik.Windows.Controls.RadGridView;
        grid.CollapseHierarchyItem(row.Item);
 
        // Force it to re-evaluate the style
        row.IsExpandable = true;
        row.IsExpandable = false;
    }
}


I'm using this in conjunction with a RowStyleSelector that exists in my xaml that sets "IsExpandable" based upon one of my properties
Tags
GridView
Asked by
TheFlo
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
TheFlo
Top achievements
Rank 1
Aaron
Top achievements
Rank 1
Share this question
or