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

GridVIewRow.DetailsVisibility does not work

1 Answer 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gonzalo Contento
Top achievements
Rank 1
Gonzalo Contento asked on 19 Jun 2012, 09:17 PM
We have the following GridView:
<telerik:RadGridView Grid.Row="2"  RowDetailsTemplate="{StaticResource FundRowDetails}"
                             RowDetailsVisibilityMode="Collapsed" 
                             Name="radGridViewFunds"
                             CanUserFreezeColumns="False"
							 AutoGenerateColumns="False" 
                             RowHeight="28" 
                             EnableColumnVirtualization="False"
						     ScrollMode="RealTime" 
                             RowIndicatorVisibility="Collapsed" 
                             IsSynchronizedWithCurrentItem="True" 
                             IsReadOnly="true"
                             LoadingRowDetails="RadGridViewFundsLoadingRowDetails" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RowActivated="RadGridViewFundsRowActivated" >
                <telerik:RadGridView.Columns>
                    <telerik:GridViewToggleRowDetailsColumn />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding CompanyName, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Company" Width="150" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding ManagerName, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Manager" Width="150" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding FamilyName, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Family" Width="150" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding StrategyName, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Strategy" Width="150" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding FundDisplayName, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Name" Width="250" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding FundCd, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Code" Width="100" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding OnOffShore, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="On/Off Shore" Width="100" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding FundSeries, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Series" Width="100" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding FundClass, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Class" Width="100" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Administrator, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Administrator" Width="100" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding ReturnType, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Return Type" Width="100" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding ReturnSource, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Return Source" Width="100" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Auditor, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Auditor" Width="100" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding StrategyGroupName, Mode=TwoWay, UpdateSourceTrigger=Default}" Header="Strategy Group Name" Width="100" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
In addition, there is a button that is used to add a new item to the gridview through the datasource.
After a new row is added, I would like to have the row expanded. Here is the code for that:

private void RadButtonNewClick(object sender, RoutedEventArgs e)
        {
            LogProcess("New button was clicked");
 
            ControlTabs.SelectedIndex = 0;
 
            checkShowAllFunds.IsChecked = true;
 
            var newFundPending = _fundList[0] != null && !_fundList[0].UpdateDtm.HasValue;
            if (newFundPending)
                return;
 
            textBoxFundNameCriteria.Text = string.Empty;
 
            LogProcess("Inserting blank fund into fund view data");
 
            var newFund = new vFund();
            _fundList.Insert(0, newFund);
 
            _newFund = newFund;
 
            LogProcess("Rebinding data");
            radGridViewFunds.ItemsSource = _fundList;
            radGridViewFunds.Rebind();
 
            radGridViewFunds.SelectedItem = newFund;
			radGridViewFunds.CurrentItem = newFund;
 
            var newRowGridItem = radGridViewFunds.ChildrenOfType<GridViewRow>().FirstOrDefault();
            if (newRowGridItem == null)
                return;
 
            radGridViewFunds.ScrollIntoView(newFund);
            radGridViewFunds.UpdateLayout();
			
            newRowGridItem.DetailsVisibility = Visibility.Visible;			
        }
However, The newRowGridItem.DetailsVisibility does not work, and the newly added row remains collapsed. How can I Programmatically expand the new row? Thanks.

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 25 Jun 2012, 06:10 AM
Hi Gonzalo, 

You can try setting DetailsVisibility in a Dispatcher once the new item is added.  


Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Gonzalo Contento
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or