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

Selecting rows in nested GridViews problem

9 Answers 140 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Roland Vonk
Top achievements
Rank 1
Roland Vonk asked on 03 Jan 2012, 03:02 PM
Hello Telerik,

We are developing and application using WPF and the MVVM design pattern.

We have a case where we've created a "dialog" to select a single value using the RadGridView where the result is selected from a nested RadGridView (the nested RadGridView's go only 1 level deep). You can see an example of our dialog in the attached screenshot.

The issue is a selection inconsistency. The issue is as follow:
a) Expand a row to reveal the embedded GridView, select a row from the embedded GridView making note of the specific cell clicked on the select the row.
b) Expand another row to reveal another embedded GridView and select a row from that embedded GridView.
c) Then try to reselect the row in "step a" by click on the exact same cell clicked on when selected the first time ... CANNOT SELECT THE ROW!

It appears that clicking on a row will still "select" the cell even though the GridView SelectionUnit is set to "FullRow". I'm assuming the solution is to prevent the cell selection altogether, but I can seem to find a solution.

Please see code below

Best Regards,
Roland

<tgrid:RadGridView x:Name="radGridView" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" Margin="6,0,6,6" VerticalAlignment="Stretch" IsReadOnly="True" RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" ScrollMode="Deferred" ItemsSource="{Binding CollectionView.ItemsSource}" DataLoadMode="Asynchronous" IsFilteringAllowed="False" ShowGroupPanel="False" ShowColumnHeaders="True" EnableColumnVirtualization="False" CanUserResizeColumns="False" CanUserDeleteRows="False" AutoGenerateColumns="False" CanUserReorderColumns="False" IsScrolling="False" ShowInsertRow="False" ValidatesOnDataErrors="None" int:RadGridViewAdapter.SortDirection="{Binding CollectionView.SortDirection, Mode=TwoWay}" int:RadGridViewAdapter.SortMember="{Binding CollectionView.SortMember, Mode=TwoWay}" Grid.RowSpan="1" SelectionMode="Single" int:RadGridViewHierarchicalAdapter.HierarchicalAdapterEnabled="True" int:RadGridViewHierarchicalAdapter.HierarchicalSelectedItemsBinding="{Binding SelectedArticles}" int:RadGridViewHierarchicalAdapter.AutoSelectLowerLevel="True" SelectionUnit="FullRow">
<tgrid:RadGridView.Columns>
<tgrid:GridViewDataColumn Header="Title" Width="*" DataMemberBinding="{Binding Title}" IsFilterable="False" IsCustomSortingEnabled="False" IsGroupable="False" IsSortable="True" UniqueName="Title" TextTrimming="WordEllipsis" />
<tgrid:GridViewDataColumn Header="Brand" Width="*" DataMemberBinding="{Binding Brand}" IsFilterable="False" IsCustomSortingEnabled="False" IsGroupable="False" IsSortable="True" UniqueName="Brand" TextTrimming="WordEllipsis" />
<tgrid:GridViewDataColumn Header="Specification}" Width="*" DataMemberBinding="{Binding Specification}" IsFilterable="False" IsCustomSortingEnabled="False" IsGroupable="False" IsSortable="True" UniqueName="Specification" TextTrimming="WordEllipsis" ToolTip="{Binding Specification}" />
<tgrid:GridViewDataColumn Header="GroupKind}" Width="*" DataMemberBinding="{Binding Kind}" IsFilterable="False" IsCustomSortingEnabled="False" IsGroupable="False" IsSortable="True" UniqueName="Kind" TextTrimming="WordEllipsis" ToolTip="{Binding Kind}" />
</tgrid:RadGridView.Columns>
<tgrid:RadGridView.ChildTableDefinitions>
<tgrid:GridViewTableDefinition>
<tgrid:GridViewTableDefinition.Relation>
<Data:PropertyRelation ParentPropertyName="Articles" />
</tgrid:GridViewTableDefinition.Relation>
</tgrid:GridViewTableDefinition>
</tgrid:RadGridView.ChildTableDefinitions>
<tgrid:RadGridView.HierarchyChildTemplate>
<DataTemplate>
<tgrid:RadGridView x:Name="radGridViewChild" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsReadOnly="True" RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" ScrollMode="Deferred" ItemsSource="{Binding Articles}" IsFilteringAllowed="False" ShowGroupPanel="False" ShowColumnHeaders="True" EnableColumnVirtualization="False" CanUserResizeColumns="False" CanUserDeleteRows="False" AutoGenerateColumns="False" CanUserReorderColumns="False" IsScrolling="False" ShowInsertRow="False" ValidatesOnDataErrors="None" Grid.RowSpan="1" SelectionMode="Extended" SelectionUnit="FullRow">
<tgrid:RadGridView.Columns>
<tgrid:GridViewDataColumn Header="Number" Width="Auto" DataMemberBinding="{Binding ArticleNumber}" IsFilterable="False" IsCustomSortingEnabled="False" IsGroupable="False" IsSortable="True" UniqueName="Number" />
<tgrid:GridViewDataColumn Header="TypeNumber" Width="Auto" DataMemberBinding="{Binding TypeNumber}" IsFilterable="False" IsCustomSortingEnabled="False" IsGroupable="False" IsSortable="True" UniqueName="TypeNumber" />
<tgrid:GridViewDataColumn Header="Description" Width="Auto" DataMemberBinding="{Binding ErpDescription}" IsFilterable="False" IsCustomSortingEnabled="False" IsGroupable="False" IsSortable="True" UniqueName="Description" />
</tgrid:RadGridView.Columns>
</tgrid:RadGridView>
</DataTemplate>
</tgrid:RadGridView.HierarchyChildTemplate>
 
<tgrid:RadGridView.ScrollPositionIndicatorTemplate>
<DataTemplate>
<TextBlock Text="{Binding Title}" FontWeight="Bold" />
</DataTemplate>
</tgrid:RadGridView.ScrollPositionIndicatorTemplate>
</tgrid:RadGridView>

9 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 04 Jan 2012, 02:14 PM
Hi Roland,

As I have understood your problem is that: 
1. You select a row in the embedded GridView
2. You want to reselect the same row by clicking on the current cell (the one you have already selected). On point c) you state that "CANNOT SELECT THE ROW" - do you mean to reselect the selected row? If so, the please notice that when the row is selected, and you select it again, then the SelectionChanged event does not fire as the selection has not changed.

 What would you want to do when the row is reselected?

Kind regards,
Didie
the Telerik team

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

0
Roland Vonk
Top achievements
Rank 1
answered on 04 Jan 2012, 02:38 PM
Hello Telerik,

This is a tricky issue to describe :-)

Let me re-trace my steps:
a) Expand 2 separate nodes in the root GridView, let the expanded nodes sub-GridViews be called A and B and each sub-GridView contains 4 columns
b) Select a row from the sub-GridView A making note which cell was used to select the row
c) Then, select a row from the sub-GridView B
d) Then, re-select the row originally selected in sub-GridView A by clicking on the same cell clicked on in step b (by clicking on this cell you will not be able to select the row)

Note that the row from sub-GridView A can be re-selected by clicking on any of the other 3 cells in the row. Only the cell that was originally selected in that row will not result in selecting the row.

Also note that after step c the clicked cell in sub-GridView A still appears to have a border indicating that is was selected. It would seem that although the row is not selected, the cell is still in a selected state.

I hope this clarifies the issue.

Regards,
Roland
0
Vera
Telerik team
answered on 05 Jan 2012, 01:45 PM
Hi Roland,

I have captured a video following the steps you provided. May I ask you to take a look at it?
As you can see, when you select a row from the child RadGridView A and then select another row from B, the previously selected row in A remains selected. 
Would you please open a support ticket to send us a simple runnable project demonstrating the problem? That way we will debug it on our side in order to provide further assistance.

I am looking forward to hearing from you.


All the best,
Vera
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Roland Vonk
Top achievements
Rank 1
answered on 05 Jan 2012, 04:57 PM
Hello Vera,

Thank you for your response.

I will try to re-produce the error in a sample from my end. But for now I'll explain what's missing from the example from what I saw in the video.

We require that only ONE selection can be made. Therefore, the action of selecting the row in sub GridView B should de-select the row in sub GridView A.

What I do see from the video that may already provide a clue to the problem, is the action of clicking on a row ALSO selects a specific cell even though we only want selection of a row (perhaps this is only the visual redering).
If you click on a row, the cell of which is also clicked gets a rectangular box surrounding it indicating that that cell has also been selected. I believe this alone is ultimately the causing the problem of not being able to re-select the row (in my case).

I will try and work on a simply example to re-produce the issue, but in the meantime if you come up with more information then I look forward to your response.

Regards,
Roland
0
Dimitrina
Telerik team
answered on 06 Jan 2012, 02:31 PM
Hello Roland,

 The GridView A and GridView B are different instances of RadGridView. If you have the requirement that "the action of selecting the row in sub GridView B should de-select the row in sub GridView A.", then you could deselect the current selection when you select an item from the other details GridView. To deselect all selected rows you may use the UnselectAll() method of the RadGridView.
 So when you select an item from GridView B, the item from GridView A will be deselected. Then you will be able to re-select the previous item on GridView A.

To achieve that you have to subscribe for the SelectionChanged event of the details GridView (defined in a RowDetailsTemplate) and implement the described solution there.

 

All the best,
Didie
the Telerik team

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

0
Roland Vonk
Top achievements
Rank 1
answered on 02 Feb 2012, 02:37 PM
Hello Didie,

Sorry for the delay on getting back to you with a sample, but I've been able to reproduce the functionality I've described in a small extraction of the architecture of our application. How can I send this file to you? It is a 1MB file containing all necessary file excluding the Telerik DLL's.

Please note that we use the MVVM design pattern in our solution and have included the "MVVM Light" package from GalaSoft. Other referenced DLL's I've included in the Libraries folder contained in the solution.

Please note that I've reproduced the functionality without embedded grids. It is simply reproduced in a single ReadOnly RadGridView with Muttiple selection enabled.

The behavior is simply that you cannot immediately re-select or immediately deselect a row by clicking on the same CELL used to deselect or select that row.

Please let me know how I can send you my solution.

Regards,
Roland
0
Vlad
Telerik team
answered on 02 Feb 2012, 02:39 PM
Hi,

 You can open support ticket and attach the project. 

Kind regards,
Vlad
the Telerik team

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

0
Nkosinathi
Top achievements
Rank 1
answered on 30 May 2016, 08:11 AM

Hi

 

I have a similar issue, when I interchange the selection between two rows, the SelectionChanged does not fire on the second time. this happens specifically when I want to remove the AddNewRow by  click on the different row, it only works on the first click. 

0
Dilyan Traykov
Telerik team
answered on 31 May 2016, 09:40 AM
Hello Nkosinathi,

Could you please elaborate on your exact setup as well as the action steps needed to reproduce the behavior you're observing at your end, as I could not quite understand from your previous post?

May I also ask whether you're using the latest version of the controls, as the issue from the previous posts was fixed with the R3 2011 release?

Ideally, providing a video for me to have a look at or opening a new support thread with a sample project for me to examine would best allow me to help you find a solution to your problem.

Thank you in advance for your cooperation.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Roland Vonk
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Roland Vonk
Top achievements
Rank 1
Vera
Telerik team
Vlad
Telerik team
Nkosinathi
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or