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

Disable GridViewToggleRowDetailsColumn for specific rows

8 Answers 231 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 24 Mar 2011, 02:49 PM
Hi there,

I use a RadGridView with a GridViewToggleRowDetailsColumn.

The detailview for the row should be available when the value of a specific cell is 'True'.
Otherwise the [+] button should be disabled.

I tried to use the 'RowLoaded' event. But It's not working until the first column is out of sight.
It seems that the indexer is switching.

Could someone explain a better way to achieve this?


Best regards
Robin

8 Answers, 1 is accepted

Sort by
0
Robin
Top achievements
Rank 1
answered on 24 Mar 2011, 04:06 PM
Hi,

I found an example by Maya Zhecheva

The Behavior is working fine, the IsExpandableProperty is bound and set to the right value of each GridViewRow.

But the indicator [+] of the GridViewToggleRowDetailsColumn is still available/enabled.

How can that be?

I'm also confused that the XAML of Mayas example got no GridViewToggleRowDetailsColumn.
Where is the [+] toggle then from?
0
Ivan Ivanov
Telerik team
answered on 24 Mar 2011, 05:02 PM
Hi Robin,

I have also prepared a sample project that implements yet another possible solution to this case. Please, refer to it and inform us if this approach meets your requirements.
As for the blog post, the visibility of the toggle button is bound to the IsExpandable property of a row. The child grid is displayed in a hierarchy, not in RowDetails. 


Regards,
Ivan Ivanov
the Telerik team
0
Robin
Top achievements
Rank 1
answered on 29 Mar 2011, 02:37 PM
Hi Ivan,

thanks for your reply.

That approach is working in my project.
But I'm wondering why the toggle button is not "grayed"?

See the screenshot.
(All toggle buttons are !IsEnabled)

Best regards
Robin
0
Ivan Ivanov
Telerik team
answered on 31 Mar 2011, 08:59 AM
Hello Robin,

Changing GridViewToggleButton's IsEnabled property doesn't affect the cell that nests it. You may try setting GridViewCell's IsEnabled property instead. Please, refer to the attached project.

Greetings,
Ivan Ivanov
the Telerik team
0
Robin
Top achievements
Rank 1
answered on 31 Mar 2011, 01:20 PM
Hi Ivan,

now it's working as expected.

Thank you


Robin
0
Robin
Top achievements
Rank 1
answered on 07 Apr 2011, 10:05 AM
Hi Ivan,

it's still not working properly.

The disabled Cell is kind of switching when user is scrolling the GridView.

First screenshot: All works well
Second screenshot: After scrolling

Here my code for the RowLoaded Event:

if (e.Row.Item != null)
      {
        if (e.Row.ChildrenOfType<GridViewCell>().First().Column.GetType() == typeof(GridViewToggleRowDetailsColumn))
        {
          if ((e.Row.Item as FaultCockpitEntry).Dispatched)
          {
            e.Row.ChildrenOfType<GridViewCell>().First().IsEnabled = true;
          }
          else
          {
            e.Row.ChildrenOfType<GridViewCell>().First().IsEnabled = false;
          }
        }
      }

Greetings
Robin
0
Accepted
Ivan Ivanov
Telerik team
answered on 07 Apr 2011, 10:25 AM
Hi Robin,

I have modified my initial project a bit. Please, have a look at it, and inform us if the new approach meets your requirements.

All the best,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Avi
Top achievements
Rank 1
answered on 27 Dec 2011, 12:23 PM
Hi,

I tried as Robin to use  'RowLoaded' event to effect IsEnabled / IsExpandable property, but with no success.
Here is my code :
private void RefundsGrid_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            if (e.DataElement != null)
            {
                
                GridViewRow row = e.Row as GridViewRow;
                Refund refund = (Refund)e.DataElement;
                if (row != null && refund != null)
                {
                   row.IsExpandable = refund.IsDivided;
 
                   OR
 
                   e.Row.ChildrenOfType<GridViewCell>()[1].ChildrenOfType<GridViewToggleButton>().First().IsEnabled =  refund.IsDivided;
                }
            }
        }
  <UserControl.Resources>      
        <DataTemplate x:Key="RefundProvisionsGridCell">
            <uc:RefundProvisionsGrid />
        </DataTemplate>
</UserControl.Resources>
 
 <telerik:RadGridView Name="RefundsGrid" ItemsSource="{Binding Refunds}" RowDetailsTemplate="{StaticResource RefundProvisionsGridCell}" RowLoaded="RefundsGrid_RowLoaded" >
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="{Binding AppStrings.Selection, Source={StaticResource StringsLocator}}"
                                        HeaderTextAlignment="Center"
                                        IsFilterable="False"
                                        IsResizable="False"
                                        IsSortable="False">
                <telerik:GridViewDataColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox HorizontalAlignment="Center"
                                  IsChecked="{Binding IsSelected, Mode=TwoWay}"
                                  IsEnabled="{Binding RelatedPolicy.RelatedCustomer.HasRefunds,Converter={StaticResource invertedBooleanConverter}}" />
                    </DataTemplate>
                </telerik:GridViewDataColumn.CellTemplate>
            </telerik:GridViewDataColumn>        
            <telerik:GridViewToggleRowDetailsColumn Width="10" IsResizable="False" />
           </telerik:RadGridView.Columns>
</telerik:RadGridView>

It's not working. it shows the "+" icon all the time and you can expend it although it get "false" value. 
What am I doing wrong ?

Thanks
Tags
GridView
Asked by
Robin
Top achievements
Rank 1
Answers by
Robin
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Avi
Top achievements
Rank 1
Share this question
or