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

How to apply a horizontal scrolling bar

3 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stavros
Top achievements
Rank 1
Stavros asked on 13 Nov 2008, 02:23 PM
I have a radgrid with fixed width columns (9) that force the header text to appear only partially.
How can I force every column to be of the header's text size and to simultaneously use a horizontal scrolling bar so that I can see all the columns?
Thank you very much.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Nov 2008, 06:14 AM
Hi,

Try setting TableLayout to Auto and Enable Scrolling for the Grid as shown below.

ASPX:
<MasterTableView DataSourceID="SqlDataSource1"     TableLayout="Auto"   > 
 

<ClientSettings   > 
   <Scrolling  AllowScroll="True" /> 
</ClientSettings> 


Shinu.
0
Stavros
Top achievements
Rank 1
answered on 14 Nov 2008, 10:20 AM
The only thing that seem to work is to add a Width="100%" in the MasterTableView tag and right below MasterTableView opening tag the following tag :

<HeaderStyle Width="200px" />
0
Dimo
Telerik team
answered on 14 Nov 2008, 10:43 AM
Hello Stavros,

Depending on the RadGrid configuration and scenario, the requested functionality is achieved in different ways. If the MasterTableView has its TableLayout set to "Auto", then you don't have to do anything in particular to make RadGrid columns expand horizontally and a scrollbar to appear.

However, if the TableLayout of the MasterTableView is needed to be "Fixed" (e.g. when using row resizing), then the columns are squashed to fit the RadGrid's width, unless you do the following:

1) Set Width to the MasterTableView in pixels

or

2) Set Width to the columns in pixels


Here is a simple page, which demonstrates the simple case, when the TableLayout is Auto:


<%@ Page Language="C#" %> 
<%@ Import Namespace="System.Data" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<script runat="server"
 
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) 
    { 
        DataTable dt = new DataTable(); 
        DataRow dr; 
        int colsNum = 30
        int rowsNum = 20
        string colName = ""
 
        for (int j = 1; j <= colsNum; j++) 
        { 
            dt.Columns.Add(String.Format("Column{0}", j)); 
        } 
 
        for (int i = 1; i <= rowsNum; i++) 
        { 
            dr = dt.NewRow(); 
 
            for (int k = 1; k <= colsNum; k++) 
            { 
                colName = String.Format("Column{0}", k); 
                dr[colName] = String.Format("{0} Row{1}", colName, i); 
            } 
            dt.Rows.Add(dr); 
        } 
 
        (sender as RadGrid).DataSource = dt
    } 
 
</script> 
 
<!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"
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>RadGrid for ASP.NET AJAX</title> 
</head> 
<body> 
<form id="form1" runat="server"
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
<telerik:RadGrid 
    ID="RadGrid1" 
    runat="server" 
    Skin="Vista" 
    OnNeedDataSource="RadGrid1_NeedDataSource"
    <ClientSettings> 
        <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
    </ClientSettings> 
</telerik:RadGrid> 
 
</form> 
</body> 
</html> 



Regards,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Stavros
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Stavros
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or