NestedViewTemplate - RadGrid - How to autosize height

4 posts, 0 answers
  1. Raka
    Raka avatar
    71 posts
    Member since:
    Sep 2011

    Posted 08 Jul Link to this post

    Good Morning

    I have a RadGrid inside a NestedViewTemplate.  I want it to auto-size its height to match number of rows in the Grid.  So if the grid is empty, it should show one row with 'No Records Found'.  If there are more rows, it should resize the height to contain those.   This is to avoid having a fixed size space with lots of blanks.

    How can I do this?

    Thank you
    Raka

  2. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 13 Jul Link to this post

    Hello Raka,

    Note that the Grid will automatically adjust the height based on the items in it if you do not set a height of the control. In case your requirement differs could you please elaborate more on your scenario?

    Regards,
    Kostadin
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Raka
    Raka avatar
    71 posts
    Member since:
    Sep 2011

    Posted 13 Jul in reply to Kostadin Link to this post

    Hello Kostadin

    Thank you for your reply.  However, it is not automatically adjusting the height.

    I have a nested grid inside the main grid.  I set the height of main grid.  If I do not set a height for NestedGrid, it picks some number and the nested grid area is big.  If I set the "ScrollHeight" for nested grid to something like '200px', then it looks reasonable.  But I want it to be automatically (dynamically) adjusted to the number of rows it contains.

    How do I do that?

    The code is below. 

    Thank you, Raka.

    Main Grid

    ===========

        <MasterTableView DataKeyNames="Id,TypeId" ClientDataKeyNames="Id,Id" AllowMultiColumnSorting="true" ShowHeader="true" Width="100%">
            <NestedViewTemplate>
                <div class="pad-md">
                    <uc1:Grid ID="rgStatus" runat="server" OnNeedDataSource="rgStatus_NeedDataSource" ShowToolBar="false" EnableScrolling="true" EnablePaging="false" ShowBorder="true" ShowSelectColumn="false" />
                </div>
            </NestedViewTemplate>
            <Columns>

            ...

            </Columns>

     

    Nested Grid

    ===========

         <telerik:RadGrid ID="rgGrid" runat="server" AutoGenerateColumns="false" OnItemCommand="rgGrid_ItemCommand" OnItemDataBound="rgGrid_ItemDataBound"
            OnNeedDataSource="rgGrid_NeedDataSource" AllowSorting="true" BorderStyle="None" AllowPaging="false" AllowMultiRowSelection="true">
            <ClientSettings>
                <Scrolling AllowScroll="False" SaveScrollPosition="False" UseStaticHeaders="true" ScrollHeight="200px" />
                <Selecting AllowRowSelect="True" EnableDragToSelectRows="false"></Selecting>
            </ClientSettings>
            <MasterTableView DataKeyNames="Id" ClientDataKeyNames="Id" AllowMultiColumnSorting="true" Width="100%">
                <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
                <Columns>

       ...

        

  5. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 18 Jul Link to this post

    Hello Raka,

    In order the grid to change the height dynamically you should not set a height neither to the MainGrid nor to the nested RadGrid. You can check out the following live example which demonstrates a NestedViewTemplate with a grid in it.

    Regards,
    Kostadin
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top