grid height inside scrollviewer

4 posts, 0 answers
  1. Colin Cowie
    Colin Cowie avatar
    10 posts
    Member since:
    May 2010

    Posted 25 Jun 2013 Link to this post

    I have a situation where we have a dataform with various tabs in it.  Some have multitudes of data fields, and some have radgrids.  So that the user is always able to view the entirety of the form regardless of the width/height of the contents relative to their screensize, the entire form content sits inside a scrollviewer.

    However, this is giving us undesirable behaviour regarding the radgrid.  When not in a scrollviewer the grid will size itself to the available height/width (it is height that I'm interested in here), and show its own internal scrollbar if there is insufficient height to display the available rows of data.

    Within the scrollviewer it sizes itself to the available height, but if the available height is insufficient, it sizes to the number of rows of data and lets the outer scrollviewer display its own scrollbars.

    I've verified in a test project that the dataform and tab control aren't getting in the way, and it works this way with just a grid inside a standard scrollviewer, and a radgrid within that.

    In our case we really want the scrollviewer only to come into effect when the fixed elements on the page force the content to be bigger than the size of the scrollviewer viewport.  We'd like the radgrid to continue to behave as before and use its own internal scrollbar.  It clearly knows the actual amount of available height, as it sizes to the full height of the page until you resize the browser such that it is smaller than that required to display the rows of data in the grid.

    Without resorting to event handlers on Grid sizechanged etc.. and setting the actual radgrid height accordingly, which we're doing currently and isn't ideal as it means requiring to make exact allowances for margins/paddings etc.. and risks the dreaded "Layout Cycle Detected" error, is there any way to get the radgrid to size as before, even though it's inside a scrollviewer?

    Thanks,

    Colin.
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 28 Jun 2013 Link to this post

    Hi Colin,

    I would recommend you to not place the RadGridView in controls/panels which will measure it with infinity. Such panels are the ScrollViewer, DockPanel, the StackPanel and Grid with Row.Height=Auto. More on how to increase the performance is described in this help article

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Colin Cowie
    Colin Cowie avatar
    10 posts
    Member since:
    May 2010

    Posted 02 Jul 2013 Link to this post

    Didie,

    As I explained in my original query we really do not have any choice.  We want the entirety of the dataform and all of its various tabs and fields to be visible/accessible regardless of its width/height and therefore it all sits inside a ScrollViewer. I realise this is not a bug with the RadGridView control itself, which is being told it has infinite height to work with.  However, the RadGridView control clearly also knows how much actual height it has to work with as it does expand itself to the bottom of its immediate container when the number of rows is too low to require it too.

    So, I was wondering if there was any way of getting the RadGridView to behave as normal, even though it is sat inside a ScrollViewer?  I have managed this in a fashion, by adding a SizeChanged event handler to the immediate container the RadGridView is sat within, and then setting the RadGridView height within the event handler.  I was wondering if there was any configuration of the control itself, or if you knew of any container/control I could sit the RadGridView within that would get it to be given the height actually taken up by its parent control as its available height rather than infinity.  Like I say I am aware this is not a bug, I am purely asking for a little assistance with a problem we are having and whether you might be aware of a solution that is more elegant and robust than my current workaround.

    Finally, I'm a little confused as to why you supplied a link on how to increase the performance of the control, I didn't query the performance?

    Regards,

    Colin.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 04 Jul 2013 Link to this post

    Hello Colin,

    If you want the GridView to work like normal inside ScrollView, then you should set its Height and Width to be fixed. Still, that way it will show its own ScrollBars. This is the option I can suggest.

    I sent you the link, so that you are aware that when the GridView is measured with infinity, the UI Virtualization does not work. This leads to performance problems when you have many items populated to the GridView.

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top