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

Keep Row In Place When Loading Data

2 Answers 31 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 22 Mar 2011, 12:32 AM
I'm using the RadTreeListView for hierarchal data.  When the user expands a row, I call a WCF service to populate the next level.  The control always scrolls to the top when doing this which is really annoying.  I have also tried to ScrollIntoView() method, but it scrolls the row to the bottom of the visible window.  What I want to do is keep the row in place so the user is not searching for the data they just expanded.

Is there an easy way to keep the row in the same location when expanding the parent row?  If not, is there a way to get the current index within the visible window so I can calculate which row to set in the ScrollIntoView() method to get the same affect?

Someone must have found a way to do this.  In my opinion, having the row the user just clicked on disappear is a bad design.  The user is expecting the parent row to still be under the mouse cursor after the click.

Any help would be appreciated.

-Scott

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 22 Mar 2011, 08:09 AM
Hi,

 I'm not sure why the treelist is scrolling to top - we don't have such problem on our demo. Can you send us an example demonstrating this? 

Kind regards,
Vlad
the Telerik team
0
Scott
Top achievements
Rank 1
answered on 22 Mar 2011, 09:52 PM
I found what was causing the issue and have found a suitable work-around.  My TreeListView has a Parent level.  Each parent can have any number of children (only going two levels deep).  When Initially loading the TreeListView, I check to see if the parent should indicate that it has any children.  If it does, I load ONLY the first child.  This allows the TreeListView to show the arrow indicating there are children available.  Then, when the parent node is expanded I load the rest of the children (kindof lazy loading).  Here is where the scrolling happens.  When retrieving the children from the WCF service, I was clearing the ObservableCollection holding the one child, then filling it again with all the results from the service call.  This forces the entire control to scroll to the top.

My work-around simply adds the children to the ObservableCollection starting with the second child (since it is already there).  Because I am no longer clearing the child's ObservableCollection, the control behaves correctly.

I hope this helps...

-Scott 
Tags
TreeListView
Asked by
Scott
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Scott
Top achievements
Rank 1
Share this question
or