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

Selection lost after updating children

4 Answers 23 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 08 Nov 2018, 07:02 AM

I have a tree list view with the following child table definition:

 

        <telerik:RadTreeListView.ChildTableDefinitions>
            <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" />
        </telerik:RadTreeListView.ChildTableDefinitions>

 

When an item that the tree list is bound to updates its child collection, the selected cells in the grid are lost. In our situation, the selected cell is on a row that is affected by the children changing.

 

Is there any way to prevent the selection from changing when the rows reload as a result of the structure changing? Or, failing that, any way to determine that the hierarchical structure is changing other than the row load and unload events? The grid is virtualized as well, so we can't tell how to distinguish between rows unloading because they have scrolled out of view, vs the hierarchical structure changing.

 

4 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 12 Nov 2018, 04:24 PM
Hello Steve,

My understanding is that you are replacing the entire child collection of an item and as a result the selected cells of the RadTreeListView are lost. This would be expected since when the collection is replaced the rows are recreated. Feel free to correct me if I am wrong in my understanding and provide some more information about your scenario.

May I ask you whether only updating the child collection instead of replacing it would be a viable approach for your scenario? If you only update the child collection, the selection will be preserved. I am attaching a small sample project where I have demonstrated this for your reference. Please, check it out and let me know if such an approach would work for you.

I am looking forward to your reply.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Steve
Top achievements
Rank 1
answered on 14 Nov 2018, 05:59 AM

Thank you for the sample, but that did not help us. I should probably clarify that by "the structure changing", I mean that the parent-child relationships within the tree are changing, for example indenting an item so that is now a child of what was previously a sibling.

 

Consider the tree:
a
    b
    c

 

Where the user selects cell c and chooses to indent it. The result is:

a
    b
        c

 

So, c is now a child of b and is no longer a child of a. I understand, of course, that this will cause new wrappers to get created and therefore they aren't the same actual "tree rows" and that is probably why they are no longer selected. Really what I need at this point is just a way to know from the control that this (the selection being lost) is happening, because it doesn't trigger the selection change event, and the row unload/load is unreliable for reasons of virtualization as described above.

0
Steve
Top achievements
Rank 1
answered on 14 Nov 2018, 06:07 AM
I may have mixed this up with another issue that we were having, so I don't remember if the selection changing event was being fired in this situation, and whether it is not I'm not sure what that would tell us. What we need is to know at the view level (i.e. code-behind) when the control is unloading/loading rows because it is rebuilding the children, vs virtualizing.
0
Dilyan Traykov
Telerik team
answered on 16 Nov 2018, 04:40 PM
Hello Steve,

Generally, speaking there's no way to tell if the unloaded event of a row is fired because of virtualization or because its underlying element was removed from the collection.

Would you find it possible to modify the project Vladimir sent in such a way so that it best replicates your scenario?  We may then be able to suggest a viable solution based on your setup.

I look forward to your reply.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeListView
Asked by
Steve
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Steve
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or