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

Dynamic Grid with Dynamic Height and Width

3 Answers 409 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Annette
Top achievements
Rank 1
Annette asked on 14 Feb 2011, 10:04 PM
I've look through all the examples on the forum and can't get my grid height and width to size dynamically.

Here is my code.

<asp:Panel ID="Panel1" runat="server" Height="100%" Width="100%"
             <telerik:RadGrid ID="grdProducts" runat="server" Skin="DMID" EnableEmbeddedSkins="False"
           AutoGenerateColumns="False" GridLines="None" GroupingEnabled="False" OnLoad="grdProducts_Load"
           OnPreRender="grdProducts_PreRender"  PageSize="5" AllowPaging="True" 
       AllowSorting="True" Width="99%">
           <HeaderContextMenu EnableEmbeddedSkins="False" CssClass="GridContextMenu GridContextMenu_DMID">
           </HeaderContextMenu>
           <MasterTableView NoMasterRecordsText="No Products available." TableLayout="Fixed" DataKeyNames="ProductID" >
                              <CommandItemSettings ExportToPdfText="Export to Pdf" />
                              <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
               </RowIndicatorColumn>
               <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
               </ExpandCollapseColumn>
               <Columns>
                   <telerik:GridBoundColumn FilterControlAltText="Filter ID column" HeaderText="ID"
                       ReadOnly="True" SortExpression="ProductID" UniqueName="ProductID" DataField="ProductID" HeaderStyle-HorizontalAlign="Center"  HeaderStyle-Width="60px" >
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn FilterControlAltText="Filter Lot column" HeaderText="Lot #"
                       ReadOnly="True" SortExpression="Lot" UniqueName="Lot" DataField="Lot" HeaderStyle-HorizontalAlign="Center"   HeaderStyle-Width="60px" >
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn FilterControlAltText="Filter Description column" HeaderText="Investigational Agent<br/>Description"
                       ReadOnly="True" SortExpression="Description" UniqueName="Description" DataField="Description" HeaderStyle-HorizontalAlign="Center"  HeaderStyle-Width="100px" >
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn FilterControlAltText="Filter UnitDosage column" HeaderText="Unit Dosage"
                       ReadOnly="True" SortExpression="UnitDosage" UniqueName="UnitDosage" DataField="UnitDosage" HeaderStyle-HorizontalAlign="Center"  HeaderStyle-Width="75px" >
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn FilterControlAltText="Filter ShipUnit column" HeaderText="Shipping<br/>Unit"
                       ReadOnly="True" SortExpression="ShipUnit" UniqueName="ShipUnit" DataField="ShipUnit" HeaderStyle-HorizontalAlign="Center"  HeaderStyle-Width="75px" >
                                          </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn FilterControlAltText="Filter Expire column" HeaderText="Expiration Date<br/>(mm/dd/yyyy)"
                       ReadOnly="True" SortExpression="Expire" UniqueName="Expire" DataType="System.DateTime"
                       DataField="Expire" DataFormatString="{0:d}"  HeaderStyle-HorizontalAlign="Center"  HeaderStyle-Width="80px" >
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn FilterControlAltText="Filter UnitsAvailable column" HeaderText="Units<br/>Available"
                       SortExpression="UnitsAvailable" UniqueName="UnitsAvailable" DataType="System.Int32"
                       DataField="UnitsAvailable"  HeaderStyle-HorizontalAlign="Center"  HeaderStyle-Width="50px" >
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn DataType="System.Int32" FilterControlAltText="Filter uRequested column"
                       HeaderText="Units<br/>Requested" SortExpression="URequested" UniqueName="uRequested"
                       DataField="URequested" HeaderStyle-HorizontalAlign="Center"  HeaderStyle-Width="50px" >
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn DataType="System.Int32" FilterControlAltText="Filter UApproved column"
                       HeaderText="Units<br/>Approved" UniqueName="UApproved" DataField="UApproved"
                       SortExpression="UApproved"  HeaderStyle-HorizontalAlign="Center"  HeaderStyle-Width="50px" >
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn FilterControlAltText="Filter UShipped column" HeaderText="Units<br/>Shipped"
                       ReadOnly="True" SortExpression="UShipped" UniqueName="UShipped" DataType="System.Int32"
                       DataField="UShipped"  HeaderStyle-HorizontalAlign="Center"  HeaderStyle-Width="50px" >
                   </telerik:GridBoundColumn>
               </Columns>
               <EditFormSettings>
                   <EditColumn InsertImageUrl="Update.gif" UpdateImageUrl="Update.gif" EditImageUrl="Edit.gif"
                       CancelImageUrl="Cancel.gif" FilterControlAltText="Filter EditCommandColumn column">
                   </EditColumn>
               </EditFormSettings>
           </MasterTableView>
           <ClientSettings Scrolling-AllowScroll="true" EnableRowHoverStyle="true" Selecting-AllowRowSelect="true">
               <Resizing AllowColumnResize="true" />
               <Scrolling AllowScroll="true" UseStaticHeaders="true"  />
           </ClientSettings>
           <FilterMenu EnableImageSprites="False" EnableEmbeddedSkins="False">
           </FilterMenu>
       </telerik:RadGrid>
   </asp:Panel>

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 16 Feb 2011, 09:54 AM
Hi Annette,

Please examine the code library below and let me know if this is what you want to achieve:
http://www.telerik.com/community/code-library/aspnet-ajax/grid/setting-100-height-and-resize-on-container-resize-for-grid-with-scrolling-and-static-headers.aspx

Greetings,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Annette
Top achievements
Rank 1
answered on 16 Feb 2011, 01:37 PM
I've tried the solution you pointed me to.   Let me explain what I'm trying to accomplish.  I have a form that users have to fill out.  On this form are input fields and a grid.  Upon selection of an Order #, the grid will populate with products relating to the Order #.  I want the grid's height to adjust so that it shows the number of products and it's width will not to go beyond the browser width. 

When I tried the first approach, I got the following jscript error.  Microsoft JScript runtime error: 'Scrolling' is null or not an object

I do have the client settings set as:  

<ClientSettings 

 

<Scrolling AllowScroll="true" UseStaticHeaders="true" />

 

</ClientSettings>

 

 

I did change the doc type to HTML 4.0.  I'm using version 2010.3.1317.35 of the grid in .NET 3.5

0
Pavlina
Telerik team
answered on 17 Feb 2011, 05:55 PM
Hi Annette,

It might be something in your specific case that is causing the error you received. So to solve the problem we should find what is the source of the problem. Can you share the code of the problematic page? We will debug it locally and see what went wrong there.

Kind regards,
Pavlina
the Telerik team
Tags
Grid
Asked by
Annette
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Annette
Top achievements
Rank 1
Share this question
or