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

Grid Resize

3 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ram
Top achievements
Rank 1
ram asked on 09 Mar 2009, 07:06 AM

Hi,

    I want to resize my grid on widow resizing. I got the sample code from telerik site, its working fine. But while I am minimizing the window the horizontal scroll bar is not come in the grid. Here i have around 14 columns in a grid so i want to scroll and view the records. Please help me on this. Here s my code.



Masterpage.master
-------------------------
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Masterpage.master.cs" Inherits="Masterpage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">

html
{
    overflow:auto;
}

html,
body,
form
{
    margin:0;
    height:100%;
}

</style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <table style="height: 90%; width: 100%;" cellpadding="0" cellspacing="0">
            <tr>
                <td style="height:90%;">
                        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                        </asp:ContentPlaceHolder>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

Resize.aspx
-------------------
<%@ Page Language="C#" MasterPageFile="~/Masterpage.master" AutoEventWireup="true" CodeFile="Resize.aspx.cs" Inherits="Resize" Title="Untitled Page" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<telerik:RadGrid
    ID="RadGrid1"
    runat="server"
    DataSourceID="XmlDataSource1"
    AllowPaging="true"
    PageSize="40"
    Width="100%"
    Height="100%"
    style="border:0;outline:none"
    >
    <MasterTableView TableLayout="Fixed" />
    <ClientSettings EnableRowHoverStyle="true">
        <Selecting AllowRowSelect="true" />
        <Scrolling AllowScroll="true" UseStaticHeaders="true" />
    </ClientSettings>
    <PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/datasource.xml" />
</asp:Content>






3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 12 Mar 2009, 07:24 AM
Hi,

If i understand you correctly, to achieve your goal you need to set TableLayout to "auto". The other solution is to set header width for each column.

If the problem still persists I will ask you to specify what the desired functionality is?

Best wishes,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ram
Top achievements
Rank 1
answered on 20 Mar 2009, 05:41 PM
Hi Georgi Krustev,

Thanks for your code. Now it's working fine. But now i am getting one new problem, i.e. when i am having four column my resize function is working fine. But when ever i am using ten column, the grid resize is not working. The code what i used is given below:
Resize.aspx 
---------------- 
<%@ Page Language="C#" MasterPageFile="~/Masterpage.master" AutoEventWireup="true" CodeFile="GridResize.aspx.cs" 
    Inherits="GridResize" Title="Untitled Page" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"
    <table style="height: 90%; width: 90%;"
        <tr> 
            <td style="height: 90%; width: 90%;" valign="top"
                <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="XmlDataSource1" AllowPaging="true" 
                    PageSize="40" Width="90%" Height="100%" Style="border: 0; outline: none"
                    <MasterTableView TableLayout="Auto"
                        <Columns> 
                            <telerik:GridBoundColumn DataField="id" HeaderText="id" SortExpression="id" 
                                UniqueName="id" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                             <telerik:GridBoundColumn DataField="id" HeaderText="id" SortExpression="id" 
                                UniqueName="id" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                             <telerik:GridBoundColumn DataField="id" HeaderText="id" SortExpression="id" 
                                UniqueName="id" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                             <telerik:GridBoundColumn DataField="id" HeaderText="id" SortExpression="id" 
                                UniqueName="id" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                             <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="firstname" HeaderText="firstname" SortExpression="firstname" 
                                UniqueName="firstname" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                            </telerik:GridBoundColumn> 
                        </Columns> 
                    </MasterTableView> 
                    <ClientSettings EnableRowHoverStyle="true"
                        <Selecting AllowRowSelect="true" /> 
                        <Scrolling AllowScroll="true" UseStaticHeaders="true" /> 
                    </ClientSettings> 
                    <PagerStyle Mode="NextPrevAndNumeric" /> 
                </telerik:RadGrid> 
                <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/datasource.xml" /> 
            </td> 
        </tr> 
    </table> 
</asp:Content> 
 
waiting for your reply...

Regards,
Ram
0
Georgi Krustev
Telerik team
answered on 23 Mar 2009, 02:55 PM
Hello Ram,

The explained behavior is expected, because the columns have a minimum width which cannot be reduced. In other words if those 10 columns are wider than the desktop the resizing will not work, and a horizontal scroll bar will be shown. If the minimum width of the displayed columns is smaller than the visible part of the desktop, the resizing of the grid will work.

Kind regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
ram
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
ram
Top achievements
Rank 1
Share this question
or