Kentico CMS 6.0 Developer's Guide

Creating a new Value

Creating a new Value

Previous topic Next topic Mail us feedback on this topic!  

Creating a new Value

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

A value is an object that can be placed into the layout of a report, which can be used to display a single scalar value returned by a query in a specified string  format.

 

The following properties of a value can be configured:

 

Display name

The name of the item in the list

Code name

Name used in your code

Query

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

Is stored procedure

Indicates if the query is a stored procedure or not.

Formatting string

You can format the displayed value using the standard .NET expressions. Examples:

 

{0} - displays the value

{0:F1} - displays the value as a floating point number with one digit displayed after the decimal point

 

You can find more details in .NET Framework documentation.

 

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

 

%%control:ReportValue?<report code name>.<value code name>%%

 

This is done automatically when the Insert button is used.

 

 

 

Writing queries for scalar value

 

The queries for scalar values may return any number of columns and rows, but the only value that will be displayed is the value in the first column of the first row of the result set.

 

Example:

 

1. Switch back to the General tab. Click New in the Values section below the layout editor. Enter the following values:

 

Display name: Number of pages with page template

Code name: PagesWithTemplate

Query:
 

SELECT COUNT(DocumentID)
FROM View_CMS_Tree_Joined
WHERE DocumentPageTemplateID IS NOT NULL

 

Is stored procedure: no

Formatting string: Pages with template: {0}

 

Click OK.

 

2. Place the cursor in the layout editor under the graph, select the new value from the drop-down list in the Values section and click Insert. A string like %%control:ReportValue?PagesByPageTemplate.PagesWithTemplate%% will be added to the text area.

 

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

 

devguide_clip1212

 

Continued in the example section of the Defining report parameters topic.