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

ScrollIntoView with EnableRowVirtualization="True"

23 Answers 412 Views
GridView
This is a migrated thread and some comments may be shown as answers.
naip
Top achievements
Rank 2
naip asked on 03 Mar 2010, 02:39 PM
Hello,

it seems, that the ScrollIntoView is not working correctly when row virtualization is used and rows the have different heights. Without row virtualization everything works fine - but with row virtualization ScrollIntoView scrolls to a position where the row may have been if all rows would have had the same height.

I guess thats by design and can not be avoided?

Best regards,
Thomas Hetzer

23 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 03 Mar 2010, 03:22 PM
Hi Thomas Hetzer,

There is a special method called ScrollIntoViewAsync. You will need our Latest Internal Build for this. Here is its signature:

/// <summary>
/// Scrolls the row containing the data item into view in an asynchronous manner.
/// </summary>
/// <remarks>
/// Since this method is asynchonous, calling it will return immediately. If you need
/// to perform a certain action once the scrolling is done use the scrollFinishedCallback
/// parameter to pass in a method to execute. The FrameworkElement parameter of this
/// method will be the row that was just scrolled.
/// </remarks>
/// <param name="dataItem">The data item to scroll into view.</param>
/// <param name="scrollFinishedCallback">The method to execute when scrolling has finished.</param>
public void ScrollIntoViewAsync(object dataItem, Action<FrameworkElement> scrollFinishedCallback)

This method will launch an asynchronous scroll request and will try to find the row. There is no guarantee that it will succeed. It may take many iterations to find the row, since, as you have noticed, when the heights are unknown, we simply approximate the supposed coordinates of where the row should be.

So what this method does is basically the following. It says "I think that this row should be there" and scrolls to this position. If if finds the row, then fine. If it does not find it, it repeats the same routine again. Until it finds it or its attempt count is reached. This is to avoid the method running forever and wandering around a grid with random row heights.

All these complications are due to virtualization. If it were turned of, the normal method would work since we would be able to do the math right since we would know all of the row heights beforehand.

Once the method has succeeded, it will execute a special callback, that is provided by you. In other words you give our method the address of your method to execute when it is finished.

You can call it like this for example:

this.ScrollIntoViewAsync(dataItem, (f) =>
            {
                  Debug.WriteLine("I have found the row: " + f.ToString());
            });

You can try this and see whether it will work in your case. I hope this helps.

Kind regards,
Ross
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
naip
Top achievements
Rank 2
answered on 03 Mar 2010, 04:11 PM
Hello Ross,

thank you very much for your answer. I have tried ScrollIntoViewAsync from the latest build (2009.3.1426.1030) - it still does not scroll to the correct row.

I check the result in the callback implementation - if the found data element is not the data element that I want to be scrolled into view, I call ScrollIntoViewAsync again, and again, and again ;)

After 4 or 5 calls the grid claims, that it has found the element I was searching for - but the grid lied to me. The row is still not visible (but a little closer ;)

Best regards,
Thomas Hetzer

0
Rossen Hristov
Telerik team
answered on 03 Mar 2010, 08:26 PM
Hello Thomas

Frankly, your idea is brilliant!

Let me introduce myself. My name is Rossen Hristov and I am the author of this asynchronous method.  In fact my logic is the same as yours. I am trying to find the row. In case I can not, I am trying again, but this time I hope that it is closer to the Viewport. There is a limit though.

Originally this method was internal, but I have decided to make it public. We use it for the editing architecture. For example, edit a property on which the grid is sorted, once you enter the new value the row you were editing goes somewhere else and we have to find it, so that you can edit the next row.

Let me tell you what cases I have struck while developing this functionality. Imagine that you have a grouped grid. Let's make it more diffucult and make the grouping 3-level. Add Virtualization, the concept that makes everything so difficult to predict, since you never really know what is coming next.

No one knows what height a group will have once it is expanded. It is undeterminable. Another example is Row Details with varying height. The Row Details of every single row can have arbitrary height. No one knows how much the row details will be high once they are scrolled into view. The whole math goes wrong.

So I am trying to use something similar to the Newton's Method for approximation in order to find the row (the root of our function).

Sometimes it works, sometimes not.

If you are able to send me a dummy sample project with those variable row heights that brakes the ScrollIntoViewAsync method I will be very happy. I would be able to debug your case and see why isn't this method finding the correct row.

I cannot promise anything at this stage, but I would very much like to have this sample data for testing purposes.

Please, accept our apologies. I would like to assure you that we are doing everything to meet our customers' expectations.

Looking forward to hearing from you, Thomas.

All the best,
Ross
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
naip
Top achievements
Rank 2
answered on 07 Mar 2010, 04:17 PM
Hello Ross,

thank you very much for your explanation. I have opened a support ticket (no 287741) and send you an example application.

Best regards,
Thomas Hetzer
0
amit
Top achievements
Rank 1
answered on 13 May 2010, 06:22 PM
Hi, I am evaluating the Telerik Silverlight grid and I am facing the same issue. I have EnableRowVirtualization="True". ScrollIntoViewAsync or ScrollIntoView doesn't scroll row that is outside of viewable area (except first 2 rows outside of viewable area)in view. I don't have groups in the grid. If I set EnableRowVirtualization="False", ScrollIntoView method works okay. Is there any fix for the issue?
0
Vlad
Telerik team
answered on 14 May 2010, 07:10 AM
Hello,

Can you post more info about your Silverlight and RadGridView versions?

Regards,
Vlad
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
amit
Top achievements
Rank 1
answered on 25 May 2010, 03:37 PM
I am using RadControls for Silverlight Q1 2010 SP1.
0
Vlad
Telerik team
answered on 25 May 2010, 03:42 PM
Hello,

Silverlight 3 or Silverlight 4?

Regards,
Vlad
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
amit
Top achievements
Rank 1
answered on 25 May 2010, 04:03 PM
Silverlight 3
0
Yordanka
Telerik team
answered on 26 May 2010, 03:15 PM
Hi amit,

We tested ScrollIntoView() and ScrollIntoViewAsync() methods when Row Virtualization is turned on and they are working correctly on our end. Could you post more details about your scenario and how these methods are defined? Thank you.

Kind regards,
Yordanka
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
Pedro
Top achievements
Rank 1
answered on 01 Apr 2011, 11:09 AM
Hello,

I have the same problem with Virtualization ON, it happens when the rows height are variable (template with textbox wrapping)
I didn't find a solution :(

Best regards,
Pedro

(Telerik Q11)
0
Yordanka
Telerik team
answered on 01 Apr 2011, 04:16 PM
Hello,

We introduced several improvements in ScrollIntoViewAsync() with our latest official version Q1 2011. Please, give it a try and let us know in case any issues occur.
 
Best wishes,
Yordanka
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
Pedro
Top achievements
Rank 1
answered on 04 Apr 2011, 10:17 AM
Hi,

We have official Q1 2011 dlls and the problem persists.

In my RadGridView I have some columns with templates containing RadRichTextBox (with HtmlDataProvider content), so my rows height are variable depending on the content of each RichText. Without Virtualization OFF it works, but when I enable virtualization my scrollview positionning is approximate (sometimes when an user Add a new row he doesnt see the new added row, so its a problem).

Best regards,
Pedro
0
Yordanka
Telerik team
answered on 05 Apr 2011, 12:40 PM
Hi,

Thank you for the feedback.
We have tried your scenario and we were able to reproduce the case when the new row in not scrolled correctly. However, we are not quite sure whether scrolling in such scenario can be improved. We will make a profound investigation and notify you as soon as we have more information.

Please, excuse us for the inconvenience caused.
 
Kind regards,
Yordanka
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
Uwe Bach
Top achievements
Rank 1
answered on 28 May 2011, 07:27 AM
Hello Telerik,

please put more energy in solving this problem.
I cannot accept, that you did not solved this problem after many years of experience.
Scrolling ito view with a regular grid, equal row heights and groups does not work!!!
I have no chance to bring my items in view. Neither Sync or Async.

Please solve it soon

regards


0
Nedyalko Nikolov
Telerik team
answered on 28 May 2011, 09:14 AM
Hello Stefan Neuwirth,

Could you confirm that you can reproduce the "ScrollIntoViewAsync" problem with our latest internal build (2011.1.0526)?

Regards,
Nedyalko Nikolov
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
Chris
Top achievements
Rank 1
answered on 15 Jul 2011, 05:54 PM
Hi Guys,

I too am having great issues with .ScrollIntoView() If EnableRowVirtualization="True".
After refreshing the grid row 1 appears at the top of the grid.
Then we execute .ScrollIntoView() and nothing happens.
If I manually scroll to the bottom of the grid then execute .ScrollIntoView() it works.

We are using Silverlight Q2 2011.

HELP!

Chris
0
andy
Top achievements
Rank 1
answered on 18 Jul 2011, 08:32 AM
Hi Chris,

Have you tried the asynchronous method ScrollIntoviewAsync?

Andy
0
Chris
Top achievements
Rank 1
answered on 18 Jul 2011, 01:04 PM
Yes and was able to get it working with the code below.

Q: Why is it the .ScrollIntoView() method cannot do soemthing like this?

It seems like this should not be necessary (much like having to write code to trap row double click...)

 

 

//=======================================================================================

 

 

 

// SCROLL INTO VIEW

 

 

 

//=======================================================================================

 

 

 

private void ScrollIntoView()

 

{

 

 

 

 

 

    foreach

 

 

(MyClass itm in this.dgrParameters.Items)

 

    {

 

 

        if (itm.Id == this._itm.Id)

 

        {

 

 

            this.IsBusy = true;

 

 

 

            this._itm = itm as MyClass;

 

 

 

            this._scrollIntoViewAttempts = 1;

 

 

 


            this
.dgrParameters.ScrollIntoViewAsync(

 

 

 

                this._itm,

 

                (f) => {

 

this.IsBusy = false; },

 

 

 

                new Action(this.ScrollIntoView_Failed));

 

 

 

            break;

 

        }

    }
}

 

 

 

private void ScrollIntoView_Failed()

 

{

 

 

    if (this._scrollIntoViewAttempts < 3)

 

    {

 

 

        this._scrollIntoViewAttempts++;

 

 

 

        this.radGridView.ScrollIntoViewAsync(

 

 

 

            this._itm,

 

            (f) => {

 

this.IsBusy = false; },

 

 

 

            new Action(this.ScrollIntoView_Failed));

 

    }

}

0
Rossen Hristov
Telerik team
answered on 18 Jul 2011, 02:08 PM
Hello Chris,

When row virtualizaion is turned on we cannot do the math for the rows which are not realized. Each row can have a different height based on its cell template and row details but we don't know this in advance. So, being unable to do the math, we have created the Async version of the method which uses Newton's method in trying to find the row that the user has requested. There is not guarantee that it will succeed after n attempts at all.

Your one option is to use the Async method and hope that it will manage to find the row.

The other option is to turn row virtualization off which will realize all rows and we will know their height and we will be able to do the math and calculate the scroll offset correctly. Then you can use the normal method.

I hope this helps.

Best wishes,
Ross
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Maxim
Top achievements
Rank 1
answered on 13 Sep 2012, 01:26 PM
Hello Telerik,

We have a project with 2 grids that must be synchronized with each other, that is selecting a row in one grid will select the corresponding row in the other. One of the grids has virtualized rows (EnableRowVirtualization="True"). And we can't make it scroll using the ScrollIntoViewAsynch method, providing a ScrollFailCallback does not help either. And we dont' have rows of variable height.

our version of the grid is 2011.3.1116.1040

I wonder if this problem has been finally solved by Telerik?

This synchronization is a critical usability issue for our application.

UPDATE:
Explicitly setting RowHeight on the grid resolved my problem.
0
Amit
Top achievements
Rank 1
answered on 24 Sep 2012, 01:52 PM
I am still facing the issue. Did Telerik manage to fix the issue? I cannot turn off Virtualization because it will hurt performance and I cannot say row height upfront.

--Amit
0
Vlad
Telerik team
answered on 25 Sep 2012, 06:41 AM
Hello,

 Can you post more info about the grid version at your end? I'm afraid that if you do not have specified RowHeight and you have too many different heights for various rows the algorithm for positioning will not work.

All the best,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Tags
GridView
Asked by
naip
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
naip
Top achievements
Rank 2
amit
Top achievements
Rank 1
Vlad
Telerik team
Yordanka
Telerik team
Pedro
Top achievements
Rank 1
Uwe Bach
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Chris
Top achievements
Rank 1
andy
Top achievements
Rank 1
Maxim
Top achievements
Rank 1
Amit
Top achievements
Rank 1
Share this question
or