ScrollIntoView with EnableRowVirtualization="True"

24 posts, 0 answers
  1. naip
    naip avatar
    25 posts
    Member since:
    Sep 2009

    Posted 03 Mar 2010 Link to this post

    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
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 03 Mar 2010 Link to this post

    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.
  3. naip
    naip avatar
    25 posts
    Member since:
    Sep 2009

    Posted 03 Mar 2010 Link to this post

    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

  4. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 03 Mar 2010 Link to this post

    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.
  5. naip
    naip avatar
    25 posts
    Member since:
    Sep 2009

    Posted 07 Mar 2010 Link to this post

    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
  6. amit
    amit avatar
    21 posts
    Member since:
    Nov 2007

    Posted 13 May 2010 Link to this post

    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?
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 14 May 2010 Link to this post

    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.
  8. amit
    amit avatar
    21 posts
    Member since:
    Nov 2007

    Posted 25 May 2010 Link to this post

    I am using RadControls for Silverlight Q1 2010 SP1.
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 25 May 2010 Link to this post

    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.
  10. amit
    amit avatar
    21 posts
    Member since:
    Nov 2007

    Posted 25 May 2010 Link to this post

    Silverlight 3
  11. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 26 May 2010 Link to this post

    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.
  12. Pedro
    Pedro avatar
    3 posts
    Member since:
    Dec 2010

    Posted 01 Apr 2011 Link to this post

    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)
  13. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 01 Apr 2011 Link to this post

    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
  14. Pedro
    Pedro avatar
    3 posts
    Member since:
    Dec 2010

    Posted 04 Apr 2011 Link to this post

    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
  15. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 05 Apr 2011 Link to this post

    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
  16. Uwe Bach
    Uwe Bach avatar
    8 posts
    Member since:
    Nov 2008

    Posted 28 May 2011 Link to this post

    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


  17. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 28 May 2011 Link to this post

    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
  18. Chris
    Chris avatar
    26 posts
    Member since:
    Jul 2010

    Posted 15 Jul 2011 Link to this post

    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
  19. andy
    andy avatar
    2 posts
    Member since:
    Apr 2007

    Posted 18 Jul 2011 Link to this post

    Hi Chris,

    Have you tried the asynchronous method ScrollIntoviewAsync?

    Andy
  20. Chris
    Chris avatar
    26 posts
    Member since:
    Jul 2010

    Posted 18 Jul 2011 Link to this post

    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));

     

        }

    }

  21. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 18 Jul 2011 Link to this post

    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!

  22. Maxim
    Maxim avatar
    1 posts
    Member since:
    Sep 2012

    Posted 13 Sep 2012 Link to this post

    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.
  23. Amit
    Amit avatar
    7 posts
    Member since:
    Nov 2010

    Posted 24 Sep 2012 Link to this post

    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
  24. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 25 Sep 2012 Link to this post

    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.

Back to Top