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

CellPadding between MasterTable And DetailTable

1 Answer 235 Views
Grid
This is a migrated thread and some comments may be shown as answers.
rD
Top achievements
Rank 1
rD asked on 17 Sep 2010, 04:29 PM
Hi
I am trying to adjust the cell padding within a gridview. I increased the cellpadding in the MasterTableView, but noticed that it also affects the space between the MasterTable and the DetailTable. How can I just have the cellpadding applied between the main rows within the master table and not have it affect the padding between the parent row and the detail table in the gridview?

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 20 Sep 2010, 08:29 AM
Hi Reni,

Please inspect the following example:

<%@ 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 = 3;
        int rowsNum = 2;
        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;
    }
 
    protected void RadGrid2_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridNestedViewItem)
        {
            e.Item.CssClass = "noPadding";
        }
    }
     
</script>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
<style type="text/css">
 
div.RadGrid_Office2007 .rgMasterTable .rgRow td,
div.RadGrid_Office2007 .rgMasterTable .rgAltRow td,
div.RadGrid_Office2007 .rgMasterTable .rgEditRow td,
div.RadGrid_Office2007 .rgMasterTable .rgFooter td,
div.RadGrid_Office2007 .rgMasterTable .rgFilterRow td,
div.RadGrid_Office2007 .rgMasterTable .rgHeader,
div.RadGrid_Office2007 .rgMasterTable .rgResizeCol,
div.RadGrid_Office2007 .rgMasterTable .rgGroupHeader td
{
    padding:14px 17px 13px;
}
 
.noPadding>td
{
    padding:0;
}
 
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<p>RadGrid with a skin</p>
 
<telerik:RadGrid
    ID="RadGrid1"
    runat="server"
    Width="800px"
    Skin="Office2007"
    OnNeedDataSource="RadGrid_NeedDataSource">
    <MasterTableView HierarchyDefaultExpanded="true">
        <DetailTables>
            <telerik:GridTableView Width="100%" />
        </DetailTables>
    </MasterTableView>
</telerik:RadGrid>
 
<br /><br />
 
<p>RadGrid with no skin</p>
 
<telerik:RadGrid
    ID="RadGrid2"
    runat="server"
    Width="800px"
    Skin=""
    OnNeedDataSource="RadGrid_NeedDataSource" OnItemCreated="RadGrid2_ItemCreated">
    <MasterTableView HierarchyDefaultExpanded="true" CellPadding="20">
        <DetailTables>
            <telerik:GridTableView Width="100%" CellPadding="20" />
        </DetailTables>
    </MasterTableView>
</telerik:RadGrid>
 
</form>
</body>
</html>


Best wishes,
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
Tags
Grid
Asked by
rD
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or