Kentico CMS 7.0 Developer's Guide

Creating new values

Creating new values

Previous topic Next topic Mail us feedback on this topic!  

Creating new values

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

A value is an object that you can place 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:

 

Default

Display name

The name of the item in the list

Code name

Name used in your code

Enable subscription

If enabled, users will be able to subscribe to the currently edited report value. To allow subscriptions, it is also necessary to have the Enable subscription box checked on the General tab of the given report.

Query

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.

Connection string

Sets the database connection string used by the value's query.

 

Only users who have the Set connection string permission for the Reporting module are allowed to change this value.

 

The system loads the list of connection strings from the <connectionStrings> section of the application's web.config file. The (default) option represents the CMSConnectionString added by the application's initial database installer.

 

You can check the Inherit box to load the Connection string value set for the parent report.

Format

Formatting string

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

 

{0} - displays the value

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

 

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.

 

 

InfoBox_Note

 

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 the New button 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%% is added to the text area.

 

Click Save Save to confirm 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.