Custom Virtualization the GridView

2 posts, 0 answers
  1. Oleg
    Oleg avatar
    42 posts
    Member since:
    Oct 2011

    Posted 11 Jan 2013 Link to this post

    Hello there!

    I searched the forum for the solution of my problem, but I didnt find the 100% right thing.
    What I have is a GridView with a Column CellTemplate. In that template I built a pretty big custom control, that contains additionally your (telerik) richtextviewer. The purpose of this GridView is - we build a chat view like in Facebook or something - with text in a richtext format, images, hyperlinks etc.

    First I tried to use GridView with disabled RowVirtualization. This works great for 0 - 100 items in my collection, but with more it becomes slow, and the loading time is not acceptable. Then I enabled the RowVirtualization and tested it. Fast loading times of the GridView and no problems with large item count in the collection - GridView draws only the items you can see. But the problem here is - while scrolling up and down (many times between the first and the tenth item for example) GridView virtualizes these items and creates and draws them everytime new. This means - scrolling is very laggy, even on my developer PC with i7-2600 CPU, 16GB Ram and SSD drive and NVidia GTX570.

    I tried the so called Cells Caching I've found somewhere here in the forums. Tried the VirtualQueryableCollectionView, nothing gives me the performance I need :(

    So, what I really need is: A GridView virtualizing offset, that I can set manually. Like a number of items in my collection that will be kept on screen/in memory. For example, if I say I want 100 items not being recycled, then only when I reach the 101th item by scrolling down, the first one will be erased from the cache. That would be perfect for our App.
    I didnt find any properties in the GridView that allow me to do such a thing. To achieve it at the moment, I need to write custom code for manually removing top items from the collection when I scroll beyond the 101th item, and also to insert it back, when I scroll back to the top.

    I hope you understand what I wanted to say :) I would be happy to get any help here :)

  2. Pavel Pavlov
    Pavel Pavlov avatar
    2039 posts

    Posted 14 Jan 2013 Link to this post


    I am afraid RadGridView ( or any other ) DataGrid on the market would  not be capable of handling such a heavy cell template.  RadGridView is designed with much lighter templates in mind - e.g. TextBox,TextBlock, combo box  etc. A control like a rich text box may often contain a visual tree with hundreds and even thousands of visuals that need to be taken care off while scrolling.

    What I can recommend for your scenario would be:

    1. Use a StackPanel to layout the multiple instances of the rich text box
    2. Actually use the rich textbox only in edit mode.

    In case you insist to use RadGridView for, please use the rich text box only in edit mode . This way you will have just a single instance of the heavy template as only a single cell may be in edit mode at a time.

    All the best,
    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top