Single Selection Across Hierarchical Grid

7 posts, 0 answers
  1. Chris
    Chris avatar
    18 posts
    Member since:
    Jan 2009

    Posted 02 Jul 2010 Link to this post

    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

  2. Chris
    Chris avatar
    18 posts
    Member since:
    Jan 2009

    Posted 02 Jul 2010 Link to this post

    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

  3. DevCraft banner
  4. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 08 Jul 2010 Link to this post

    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
  5. ganesh
    ganesh avatar
    2 posts
    Member since:
    May 2015

    Posted 21 May 2015 Link to this post

    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

     

  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 22 May 2015 Link to this post

    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
  7. ganesh
    ganesh avatar
    2 posts
    Member since:
    May 2015

    Posted 22 May 2015 in reply to Dimitrina Link to this post

    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

     

  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 May 2015 Link to this post

    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
Back to Top
DevCraft banner