Kentico CMS 6.0 Developer's Guide

Creating a new Table

Creating a new Table

Previous topic Next topic Mail us feedback on this topic!  

Creating a new Table

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

A table can be placed into the layout of a report and can be used to display data retrieved from the Kentico CMS database by a query.


The following properties can be used to configure tables:


Display name

The name of the table shown in the user interface.

Code name

Name used in your code.

Enable export

If enabled, users who view the table will be able to export the displayed data to external files using the Microsoft Excel (XLSX), CSV or XML format. The data export feature may be accessed by right‑clicking the table in the report, which will open a context menu with possible export actions.


Here you can add the SQL query used to retrieve data to be displayed by the table.

Is stored procedure

Indicates if the query is a stored procedure or not.

No record text

Text to be displayed if the query doesn't return any data.

Skin ID

ID of the .NET skin (stored in the .skin files in ~/AppThemes/<theme name>) which will be used for the table.

Enable paging

If enabled, paging will be enabled when the report table is displayed. The paging can be configured by the two properties below.

Page size

Number of table rows per page.

Paging mode

Type of paging controls displayed below the table. The following options are available:


Previous-next buttons - displays buttons leading to the previous and next page

Page numbers - displays page numbers leading to the corresponding pages

Previous-next-first-last buttons - displays buttons leading to the first, last, previous and next page

Page numbers-first-last buttons - displays page numbers leading to the corresponding pages and buttons leading to the first and last page


Tables are entered into the report layout editor as an expression in the following format:


%%control:ReportTable?<report code name>.<table code name>%%


This is done automatically when the Insert button is used.




Writing queries for tables


The queries you write for tables are standard SQL queries that pull data from the Kentico CMS database. You can find the description of Kentico CMS database tables and views in Kentico CMS Database Reference that is a part of the standard installation.


For information about documents, you can use the View_CMS_Tree_Joined table that returns published versions of all documents.


Table column names


The table column names use the same names as the column names from the returned data set. If you need to use user friendly names, you can use the following syntax in the query:


SELECT PageTemplateDisplayName AS [Template Name], ...





1. Click New in the Tables section below the layout editor. Enter the following values:


Display name: Pages by Page Template

Code name: PagesByPageTemplate


SELECT PageTemplateDisplayName AS [Template Name], DocumentNamePath AS [Document]
FROM View_CMS_Tree_Joined
LEFT JOIN CMS_PageTemplate
ON CMS_PageTemplate.PageTemplateID = View_CMS_Tree_Joined.DocumentPageTemplateID
WHERE PageTemplateDisplayName IS NOT NULL AND PageTemplateIsReusable = 1
ORDER BY PageTemplateDisplayName


Is stored procedure: no

SkinID: leave empty

Enable paging: enabled

Page size: 10

Page mode: Page numbers


Click OK.


2. Now place the cursor in the layout editor on a new line under the title, select the table from the drop-down list in the Tables section and click Insert. A string like %%control:ReportTable?PagesByPageTemplate.PagesByPageTemplate%% will be added to the text area.


Click Save to save the changes and switch to the View tab. You will see a report like this:




Continued in the example section of the Creating a new Graph topic.