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

Single Selection Across Hierarchical Grid

6 Answers 82 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 02 Jul 2010, 11:15 PM
I was wondering if it is possible to have a single row selected across a hierarchical grid. I want to be able to have whatever row the user selects, whether it's in a parent grid or child grid to be the "active" row. This is so we can have the buttons in the toolbar perform actions on this "active" row. This was working for us in a previous version, Q3 2009, but isn't working anymore. We were binding the SelectedItem property in all the grids to a single property in the Grid's DataContext. I haven't figured out exactly what is happening but it looks like when a grid row is expanded to show it's children the first row is selected but the SelectedItem property is never updated. Also, it's not possible to switch from the child to the parent row because clicking on the row doesn't cause the SelectedItem property to update. This would appear to make sense because the when an item in the child grid is selected it looks like the parent row is also selected. Is there a way to change this behavior? Like so if a ChildRow is selected the parent row becomes un-selected? This just worked in the old version but now does not. I've also tried binding to the CurrentItem property but this doesn't work either.

Thanks,
Chris

6 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 02 Jul 2010, 11:46 PM
Ok, I figured out what was happening. The way the binding was setup doesn't work anymore. I'm not sure if it's a Silverlight 4 issue or if something changed with Telerik. I am trying to bind the SelectedItem property of the child grid to a property of the DataContext of the page. I was doing this previously with something like this:

        <telerikGridView:RadGridView 
                    x:FieldModifier="public"  
                    x:Name="Grid1" 
                    SelectedItem="{Binding SelectedItem,Mode=TwoWay}" 
                    ItemsSource="{Binding SomeItems}" 
                    > 
            <telerikGridView:RadGridView.ChildTableDefinitions> 
                <telerikGridView:GridViewTableDefinition /> 
            </telerikGridView:RadGridView.ChildTableDefinitions> 
            <telerikGridView:RadGridView.HierarchyChildTemplate> 
                <DataTemplate> 
                    <telerikGridView:RadGridView 
                        x:Name="Grid2" 
                        x:FieldModifier="public"  
                        ItemsSource="{Binding ChildItems}" 
                        SelectedItem="{Binding DataContext.SelectedItem,Mode=TwoWay,ElementName=Grid1}" 
                        /> 
                </DataTemplate> 
            </telerikGridView:RadGridView.HierarchyChildTemplate> 
        </telerikGridView:RadGridView> 

I changed the binding for the child grid to be done programmatically in the code behind on the Loaded event of the child grid. This worked as expected. I would rather be able to define this in the Xaml though instead of using code behind. Is there a way I can do this using markup?

Thanks,
Chris

0
Milan
Telerik team
answered on 08 Jul 2010, 01:04 PM
Hello Chris,

It is actually very strange that the setup was working in the past since you cannot create such bindings in DataTemplates. Nevertheless I am glad that you have found a workaround. 

Do not hesitate to write if you need more help.


Greetings,
Milan
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
ganesh
Top achievements
Rank 1
answered on 21 May 2015, 11:17 AM

Hi ,

 

I am using RadGridview for 3 levels of hierarchy.

I want the parent row to be selected whenever the child row is selected.

I tried to set it in the SectionChanged event but its not working. Please let me know if there is any solution.

Regards,

Ganesh

 

0
Dimitrina
Telerik team
answered on 22 May 2015, 01:03 PM
Hi Ganesh,

There is not such a built-in option of selection between the hierarchy levels. You can try extending the existing functionality by subscribing for the SelectedChanged events on each details level and handle it as per your requirements. 

You can also check the following forum thread: RadGridView - Hierarchy - Selected Parents and Childs.

Regards,
Dimitrina
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
ganesh
Top achievements
Rank 1
answered on 22 May 2015, 01:47 PM

Thanks Dimitrina . I will try it.

I have another issue regarding the RadGridView commit edit on focus lost.

I am setting grid properties ActionOnLostFocus="CommitEdit"  EditTriggers="CellClick"

 

Still, whenever I click on some other control not part of the grid, the value commit is not happening.

 

eg. I enter some value in the grid cell. and don't press enter. Now I click on the save button in toolbar. It doesn't get the latest value entered in the cell as the commit on focus hasn't finished.

 

Regards,

Ganesh

 

0
Dimitrina
Telerik team
answered on 26 May 2015, 10:28 AM
Hello Ganesh,

I performed some tests and as it turns out I am not able to reproduce an issue when configuring RadGridView with ActionOnLostFocus="CommitEdit"  EditTriggers="CellClick", editing a cell and then clicking on a button outside RadGridView.
Since this thread is on another topic, I attached my test application in the support ticket you opened on the same question. We can continue further communication there.

Regards,
Dimitrina
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Milan
Telerik team
ganesh
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or