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

White space inside the telerik grid

2 Answers 150 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joseph Hua
Top achievements
Rank 1
Joseph Hua asked on 10 Jun 2010, 08:58 PM
I have a telerik grid with one templete column of several controls(labels, telerik grid, html tables), and it renders with extra padding and white space inside the grid. I have the same structure asp grid, but it does not render any extra padding and white space. Can any one tell me why?

Thanks for help!

Joseph Hua

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 14 Jun 2010, 04:02 PM
Hi Joseph Hua,

RadGrid table cells have a default padding. You can remove or modify it like this:


<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<script runat="server">
 
    protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable dt = new DataTable();
        DataRow dr;
        int colsNum = 4;
        int rowsNum = 8;
        string colName = "Column";
 
        for (int j = 1; j <= colsNum; j++)
        {
            dt.Columns.Add(String.Format("{0}{1}", colName, j));
        }
 
        for (int i = 1; i <= rowsNum; i++)
        {
            dr = dt.NewRow();
 
            for (int k = 1; k <= colsNum; k++)
            {
                dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1} Row{2}", colName, k, i);
            }
            dt.Rows.Add(dr);
        }
 
        (sender as RadGrid).DataSource = dt;
    }
     
</script>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head id="Head1" runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
<style type="text/css">
 
div.MyGrid .rgHeader,
div.MyGrid th.rgResizeCol,
div.MyGrid .rgFilterRow td,
div.MyGrid .rgGroupHeader td,
div.MyGrid .rgRow td,
div.MyGrid .rgAltRow td,
div.MyGrid .rgEditRow td,
div.MyGrid .rgFooterRow td
{
    padding:0;
}
 
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<telerik:RadGrid
    ID="RadGrid1"
    runat="server"
    Skin="Office2007"
    Width="800px"
    CssClass="MyGrid"
    AllowFilteringByColumn="true"
    OnNeedDataSource="RadGrid_NeedDataSource">
     
</telerik:RadGrid>
 
 
</form>
</body>
</html>


Regards,
Dimo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Joseph Hua
Top achievements
Rank 1
answered on 14 Jun 2010, 05:09 PM
Thanks for the help!

It really works.

Joseph Hua
Tags
Grid
Asked by
Joseph Hua
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Joseph Hua
Top achievements
Rank 1
Share this question
or