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

[Solved] RadGridView RowDetails Issue

4 Answers 177 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Meehir
Top achievements
Rank 1
Meehir asked on 20 Jan 2011, 10:31 AM
Hi,

We are using Telerik RadGridView for our project where we need a row details as a RadGridView. We have done the coding as below which is working fine:

 

<UserControl.Resources>
  <
my:XYZViewModel x:Key="MyViewModel" />
    <DataTemplate x:Key="XYZDetailsTemplate">
      <telerik:RadGridView AutoGenerateColumns="False" ShowGroupPanel="False"
                    ItemsSource="{Binding XYZDetailsList, Mode=TwoWay, Source={StaticResource MyViewModel}}"
                    SelectedItem="{Binding SelectedXYZDetail, Mode=TwoWay, Source={StaticResource MyViewModel}}"   
                    IsSynchronizedWithCurrentItem
="False" FrozenColumnCount="1"
                    CanUserInsertRows="True" CanUserDeleteRows="True" ShowInsertRow ="True"                                    
                    mvvmcmd
:RadGridViewCellEditEnded.Command="{Binding XYZDetailsCellEditEndedCommand, Source={StaticResource MyViewModel}}"
                    mvvmcmd:RadGridViewDeleting.Command="{Binding XYZDetailsDeletingCommand, Source={StaticResource MyViewModel}}"
                    mvvmcmd:RadGridViewAddingNewDataItem.Command="{Binding XYZDetailsAddingNewDataItemCommand, Source={StaticResource MyViewModel}}">
        <
telerik:RadGridView.Columns>
          <
telerik:GridViewDataColumn Header="Action" DataMemberBinding="{Binding Action}"
                                    IsReadOnly
="True"></telerik:GridViewDataColumn>
            <
telerik:GridViewDataColumn Header="From" DataMemberBinding="{Binding From}"></telerik:GridViewDataColumn>
            <
telerik:GridViewDataColumn Header="To" DataMemberBinding="{Binding To}"></telerik:GridViewDataColumn>
            <
telerik:GridViewDataColumn Header="X Amount" DataMemberBinding="{Binding XAmt}"></telerik:GridViewDataColumn>
            <
telerik:GridViewDataColumn Header="Y Amount" DataMemberBinding="{Binding YAmt}"></telerik:GridViewDataColumn>
            <
telerik:GridViewDataColumn Header="Z Amount" DataMemberBinding="{Binding ZAmt}"></telerik:GridViewDataColumn>
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>
  </
DataTemplate>
</
UserControl.Resources>

<
Grid Grid.Row="2" Grid.ColumnSpan="2">
  <
telerik:RadGridView x:Name="Main" Margin="5" CanUserFreezeColumns="False" ItemsSource="{Binding MainList, Mode=TwoWay}" RowDetailsTemplate="{StaticResource XYZDetailsTemplate}" SelectedItem="{Binding SelectedMain, Mode=TwoWay}" FrozenColumnCount="1" AutoGenerateColumns="False"  HorizontalAlignment="Left" CanUserInsertRows="True" CanUserDeleteRows="True"
mvvmcommands:RadGridViewCellEditEnded.Command="{Binding CellEditEndedCommand}" mvvmcommands:RadGridViewDeleting.Command="{Binding DeletingCommand}" mvvmcommands:RadGridViewAddingNewDataItem.Command="{Binding AddingNewDataItemCommand}" mvvmcommands:RadGridViewRowDetailsVisibilityChanged.Command="{Binding RowDetailsVisibilityChanged}" SelectionMode="Extended">
  <
telerik:RadGridView.Columns>
    <telerik:GridViewToggleRowDetailsColumn Header="+"></telerik:GridViewToggleRowDetailsColumn>
    <
telerik:GridViewDataColumn Header="Action" DataMemberBinding="{Binding Action}" IsReadOnly="True"></telerik:GridViewDataColumn>
    <
telerik:GridViewDataColumn Header="From Date" DataMemberBinding="{Binding StartDate}"></telerik:GridViewDataColumn>
    <
telerik:GridViewDataColumn Header="To Date" DataMemberBinding="{Binding EndDate}"></telerik:GridViewDataColumn>
  </
telerik:RadGridView.Columns>
  </
telerik:RadGridView>
</
Grid>

 

We have Main grid and the rowdetails contain XYZ grid. The details of XYZ grid is depends on main grid selected row. If we select particular row, and then expand rowdetails using ToggleRowDetailsColumn, it calls binding property of XYZ grid itemsource (

 

XYZDetailsList), it populates the XYZ grid based on evaluating selected row (the binding property is SelectedMain) of Main grid.

 

The problem is, when we directly click GridViewToggleRowDetailsColumn of Main grid without selecting any row, it tries to call

 

XYZDetailsList get property. In this property, it tries to get details of SelectedMain and based on that itself, it populates XYZDetailsList. But, the SelectedMain is null as it was not selected.

 

I have also added RowDetailsVisibilityChanged event in the form of commands, wherein I have written the code to select current row on expanding the row, but the

 

XYZDetailsList get property first before this event, so it leads to wrong result.

 

I hope you understand my query. Kindly resolve my query. Thanks in advance

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 20 Jan 2011, 10:35 AM
Hello,

 Have you tried RowDetailsVisibilityChanging event instead? 

All the best,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Meehir
Top achievements
Rank 1
answered on 20 Jan 2011, 11:53 AM
Thanks Vlad,

I dont see RowDetailsVisibilityChanging event in my case, may be I dont have latest dlls.  Kindly provide me with the link of latest dll.  Also, suggest any other solution to my problem.

Thanks,
Meehir Jha
0
Meehir
Top achievements
Rank 1
answered on 21 Jan 2011, 01:39 PM
Hi,

I think I dont have that event, so I have a workaround to this.  But i dont know how to implement. 

After loading the data, I want the GridViewToggleRowDetailsColumn column to be disable.  When I select particular row, (say second row) the the toggle button of that row will be enabled and others will be disabled.  If I re-select 3rd row, then the toggle button of second row will be disable and the third row will be enable.

I have tried a lot, but couldn't succeed.  Kindly help me, if any of you have any solution to this.

Thanks in Advance,
Meehir  Jha
0
Vlad
Telerik team
answered on 21 Jan 2011, 02:09 PM
Hi Meehir,

 I'm sorry - I've spoke to soon this is still unreleased. I've noticed however that you have set SelectionMode="Extended" however your child data depends on parent grid row selection - I'm not sure how this will work if you select more than one item. Maybe it will be better to use the current DataContext for the child grid (which is parent row) instead selected row in the parent grid to retrieve your child data. 

Best wishes,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Meehir
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Meehir
Top achievements
Rank 1
Share this question
or