New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Predefined Table Styles

Using TableLayoutCssFile property

  • Show/Hide Border
  • Table Properties
  • Delete Table
  • Row
    • Insert Row Above
    • Insert Row Below
    • Delete Row
  • Column
    • Insert Column to the Left
    • Insert Column to the Right
    • Delete Column
  • Cell
    • Merge Cells Horizontally
    • Merge Cells Vertically
    • Split Cell Horizontally
    • Split Cell Vertically
    • Delete Cell
  • Cell Properties
  • Table Properties
  • Properties...
  • Image Map Editor
  • Properties...
  • OpenLink
  • Remove Link
  • Insert Select
  • Cut
  • Copy
  • Paste
  • Paste from Word
  • Paste Plain Text
  • Paste As Html
  • Paste Html

RadEditor with default CSS Layout

  • Show/Hide Border
  • Table Properties
  • Delete Table
  • Row
    • Insert Row Above
    • Insert Row Below
    • Delete Row
  • Column
    • Insert Column to the Left
    • Insert Column to the Right
    • Delete Column
  • Cell
    • Merge Cells Horizontally
    • Merge Cells Vertically
    • Split Cell Horizontally
    • Split Cell Vertically
    • Delete Cell
  • Cell Properties
  • Table Properties
  • Properties...
  • Image Map Editor
  • Properties...
  • OpenLink
  • Remove Link
  • Insert Select
  • Cut
  • Copy
  • Paste
  • Paste from Word
  • Paste Plain Text
  • Paste As Html
  • Paste Html

The "CSS Class Layout" tool in the "Table Properties" dialog

It is a common scenario to style a table with CSS classes for increased clarity and visual appeal. Manually setting class name to each individual cell and row is a slow and tedious task.

The "CSS Class Layout" tool available in the "Table Properties" dialog makes the task real easy by allowing the user to style a new, or existing tables completely by choosing a table layout form a drop down (similar to visual studio design time). The "CSS Class Layout" tool contains a number of built in layouts. If a user chooses one, a style tag is inserted to the edited content.

In addition to this, developers can also specify their own style sheet files which fit better the layout of their applications. The external Style sheet can be edit by using the TableLayoutCssFile property of the RadEditor. In this case the editor will not insert a style tag in to its content area, so one would need to make sure that this external style sheet file is also imported in the page where the edited content will be displayed. In the custom css file can be inserted multiple table CSS layouts. Each layout consists of number of CSS style classes following certain naming conventions.

For example, here is how a table layout should be constructed. There is one main class (myClass) that will be applied on the table. All other classes should contain the name of the main class plus a respective suffix (for example: myClassTableHeaderRow).

These are the classes for a layout with main class myClass:

Relevant CSS Selectors

Table class

.myClassTable {}

Table Header classes

.myClassTable tr.myClassTableHeaderRow {}
.myClassTable td.myClassTableHeaderFirstCol {}
.myClassTable td.myClassTableHeaderLastCol {}
.myClassTable td.myClassTableHeaderOddCol {}
.myClassTable td.myClassTableHeaderEvenCol {}

Table Body classes

.myClassTable tr.myClassTableOddRow {}
.myClassTable tr.myClassTableEvenRow {}
.myClassTable td.myClassTableFirstCol {}
.myClassTable td.myClassTableLastCol {}
.myClassTable td.myClassTableOddCol {}
.myClassTable td.myClassTableEvenCol {}

Table Footer classes

.myClassTable tr.myClassTableFooterRow {}
.myClassTable td.myClassTableFooterFirstCol {}
.myClassTable td.myClassTableFooterLastCol {}
.myClassTable td.myClassTableFooterOddCol {}
.myClassTable td.myClassTableFooterEvenCol {}

You can also examine how the TableLayoutCss.css file, used in this demo is created.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • TableLayoutCss.css
<%@ Page Theme="Default" Language="C#" Debug="true" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs"Inherits="Telerik.Web.Examples.Editor.TableLayoutCssFile.DefaultCS"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
<link href="../Common/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-containers">
        <div class="demo-container">
            <h2>Using TableLayoutCssFile property</h2>
            <telerik:RadEditor RenderMode="Lightweight" ID="RadEditor1" runat="server" TableLayoutCssFile="TableLayoutCss.css" >
                <Content>
                    <table class="purpletable" style="margin-top: 25px; width: 500px;">
                        <thead>
                            <tr class="purpletableTableHeaderRow">
                                <th class="purpletableTableHeaderFirstCol">Browser/OS</th>
                                <th class="purpletableTableHeaderOddCol">Windows</th>
                                <th class="purpletableTableHeaderEvenCol">Mac OS</th>
                                <th class="purpletableTableHeaderLastCol">Linux</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="purpletableTableOddRow">
                                <td class="purpletableTableFirstCol" valign="top"><img alt="internet explorer" src="../../images/BrowserIcons/ie.gif" /> Internet Explorer</td>
                                <td class="purpletableTableOddCol" valign="top">6.0+</td>
                                <td class="purpletableTableEvenCol" valign="top">- </td>
                                <td class="purpletableTableLastCol" valign="top">- </td>
                            </tr>
                            <tr class="purpletableTableEvenRow">
                                <td class="purpletableTableFirstCol"><img alt="firefox" src="../../images/BrowserIcons/ff.gif" /> Firefox</td>
                                <td class="purpletableTableOddCol">1.5+</td>
                                <td class="purpletableTableEvenCol">1.5+</td>
                                <td class="purpletableTableLastCol">1.5+</td>
                            </tr>
                            <tr class="purpletableTableOddRow">
                                <td class="purpletableTableFirstCol"><img alt="chrome" src="../../images/BrowserIcons/chrome.gif" /> Google Chrome</td>
                                <td class="purpletableTableOddCol">0.2+</td>
                                <td class="purpletableTableEvenCol">5.0+</td>
                                <td class="purpletableTableLastCol">5.0+</td>
                            </tr>
                            <tr class="purpletableTableEvenRow">
                                <td class="purpletableTableFirstCol"><img alt="opera" src="../../images/BrowserIcons/opera.gif" /> Opera</td>
                                <td class="purpletableTableOddCol">9.0+</td>
                                <td class="purpletableTableEvenCol">9.0+</td>
                                <td class="purpletableTableLastCol">-</td>
                            </tr>
                            <tr class="purpletableTableFooterRow">
                                <td class="purpletableTableFirstCol"><img alt="safari" src="../../images/BrowserIcons/safari.gif" /> Safari</td>
                                <td class="purpletableTableOddCol">3.0+</td>
                                <td class="purpletableTableEvenCol">3.0+</td>
                                <td class="purpletableTableLastCol">-</td>
                            </tr>
                        </tbody>
                    </table>
                </Content>
            </telerik:RadEditor>
        </div>

        <div class="demo-container">
        <h2>RadEditor with default CSS Layout</h2>
        <telerik:RadEditor RenderMode="Lightweight" ID="RadEditor2" runat="server" >
            <Content>
                    <table class="telerik-reTable-1" style="margin-top: 25px; width: 500px;">
                    <thead>
                        <tr class="telerik-reTableHeaderRow-1">
                            <th class="telerik-reTableHeaderFirstCol-1">Browser/OS</th>
                            <th class="telerik-reTableHeaderOddCol-1">Windows</th>
                            <th class="telerik-reTableHeaderEvenCol-1">Mac OS</th>
                            <th class="telerik-reTableHeaderLastCol-1">Linux</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="telerik-reTableOddRow-1">
                            <td class="telerik-reTableFirstCol-1" valign="top"><img alt="internet explorer" src="../../images/BrowserIcons/ie.gif" /> Internet Explorer</td>
                            <td class="telerik-reTableOddCol-1" valign="top">6.0+</td>
                            <td class="telerik-reTableEvenCol-1" valign="top">- </td>
                            <td class="telerik-reTableLastCol-1" valign="top">- </td>
                        </tr>
                        <tr class="telerik-reTableEvenRow-1">
                            <td class="telerik-reTableFirstCol-1"><img alt="firefox" src="../../images/BrowserIcons/ff.gif" /> Firefox</td>
                            <td class="telerik-reTableOddCol-1">1.5+</td>
                            <td class="telerik-reTableEvenCol-1">1.5+</td>
                            <td class="telerik-reTableLastCol-1">1.5+</td>
                        </tr>
                        <tr class="telerik-reTableOddRow-1">
                            <td class="telerik-reTableFirstCol-1"><img alt="chrome" src="../../images/BrowserIcons/chrome.gif" /> Google Chrome</td>
                            <td class="telerik-reTableOddCol-1">0.2+</td>
                            <td class="telerik-reTableEvenCol-1">5.0+</td>
                            <td class="telerik-reTableLastCol-1">5.0+</td>
                        </tr>
                        <tr class="telerik-reTableEvenRow-1">
                            <td class="telerik-reTableFirstCol-1"><img alt="opera" src="../../images/BrowserIcons/opera.gif" /> Opera</td>
                            <td class="telerik-reTableOddCol-1">9.0+</td>
                            <td class="telerik-reTableEvenCol-1">9.0+</td>
                            <td class="telerik-reTableLastCol-1">-</td>
                        </tr>
                        <tr class="telerik-reTableFooterRow-1">
                            <td class="telerik-reTableFirstCol-1"><img alt="safari" src="../../images/BrowserIcons/safari.gif" /> Safari</td>
                            <td class="telerik-reTableOddCol-1">3.0+</td>
                            <td class="telerik-reTableEvenCol-1">3.0+</td>
                            <td class="telerik-reTableLastCol-1">-</td>
                        </tr>
                    </tbody>
                </table>
                <style id="telerik-reTable-1" type="text/css">
                    .telerik-reTable-1 {
                        border-bottom: 0px;
                        border-left: 0px;
                        border-collapse: collapse;
                        font-family: Tahoma;
                        border-top: 0px;
                        border-right: 0px;
                    }

                        .telerik-reTable-1 TR.telerik-reTableHeaderRow-1 {
                            text-align: left;
                            padding-bottom: 10px;
                            line-height: 14pt;
                            text-transform: capitalize;
                            font-style: normal;
                            margin: 10px;
                            padding-left: 10px;
                            border-spacing: 10px;
                            padding-right: 10px;
                            font-family: Tahoma;
                            background: #d6e8ff;
                            color: #3f4d6b;
                            font-size: 10pt;
                            vertical-align: top;
                            font-weight: bold;
                            padding-top: 10px;
                        }

                        .telerik-reTable-1 TD.telerik-reTableHeaderFirstCol-1 {
                            padding-bottom: 0in;
                            line-height: 14pt;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            color: #3a4663;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TD.telerik-reTableHeaderLastCol-1 {
                            padding-bottom: 0in;
                            line-height: 14pt;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            color: #3a4663;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TD.telerik-reTableHeaderOddCol-1 {
                            padding-bottom: 0in;
                            line-height: 14pt;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            color: #3a4663;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TD.telerik-reTableHeaderEvenCol-1 {
                            padding-bottom: 0in;
                            line-height: 14pt;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            color: #3a4663;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TR.telerik-reTableOddRow-1 {
                            background-color: #f2f3f4;
                            color: #666666;
                            font-size: 10pt;
                            vertical-align: top;
                        }

                        .telerik-reTable-1 TR.telerik-reTableEvenRow-1 {
                            background-color: #e7ebf7;
                            color: #666666;
                            font-size: 10pt;
                            vertical-align: top;
                        }

                        .telerik-reTable-1 TD.telerik-reTableFirstCol-1 {
                            padding-bottom: 0in;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TD.telerik-reTableLastCol-1 {
                            padding-bottom: 0in;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TD.telerik-reTableOddCol-1 {
                            padding-bottom: 0in;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TD.telerik-reTableEvenCol-1 {
                            padding-bottom: 0in;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TR.telerik-reTableFooterRow-1 {
                            line-height: 11pt;
                            background-color: #d6e8ff;
                            font-family: Tahoma;
                            color: #4a5a80;
                            font-size: 10pt;
                            font-weight: 500;
                        }

                        .telerik-reTable-1 TD.telerik-reTableFooterFirstCol-1 {
                            text-align: left;
                            padding-bottom: 0in;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            border-top: gray 1pt solid;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TD.telerik-reTableFooterLastCol-1 {
                            text-align: left;
                            padding-bottom: 0in;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            border-top: gray 1pt solid;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TD.telerik-reTableFooterOddCol-1 {
                            text-align: left;
                            padding-bottom: 0in;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            border-top: gray 1pt solid;
                            padding-top: 0in;
                        }

                        .telerik-reTable-1 TD.telerik-reTableFooterEvenCol-1 {
                            text-align: left;
                            padding-bottom: 0in;
                            padding-left: 5.4pt;
                            padding-right: 5.4pt;
                            border-top: gray 1pt solid;
                            padding-top: 0in;
                        }
                </style>
            </Content>
        </telerik:RadEditor>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance