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

NestedViewTemplate - RadGrid - How to autosize height

3 Answers 151 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Raka
Top achievements
Rank 1
Raka asked on 08 Jul 2016, 11:20 AM

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

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 13 Jul 2016, 09:51 AM
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.
0
Raka
Top achievements
Rank 1
answered on 13 Jul 2016, 01:50 PM

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>

   ...

    

0
Kostadin
Telerik team
answered on 18 Jul 2016, 06:55 AM
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.
Tags
General Discussions
Asked by
Raka
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Raka
Top achievements
Rank 1
Share this question
or