Tuesday 28 May 2013

Exporting Reports with Report Viewer 2012

There is a known bug in the Report Viewer 11 component which results in the export of some reports either timing out or taking exponentially longer to complete than previously, especially with large datasets. This is due to Code Access Security (CAS) changes implemented in ASP.net 4. It does not seem as if Microsoft is releasing a fix for it but fortunately there is a work-around. It mostly affects reports using Groupings so one option is to rewrite these to use other report controls. This is not ideal so you can also add the following to the <system.web> your web.config file if you experience this issue.

<trust legacyCasModel="true" level="Full"/>

This reverts the CAS level to ASP.net 3.5. Since we have added all the dll's and 'trust them' this shouldn't have an effect on anything else in Stadium. We have run the build with this change through the automated tests and everything passes.

Additionally, if you are still running Report Server 2005, you cannot view remote reports with Report Viewer 2012. Microsoft only extended backwards compatibility to Reporting Services 2008. If you are affected by this and have no plan to upgrade to a newer version of SQL soon let me know so I can assess the impact and see what can be done to accommodate you.

Thursday 16 May 2013

FormatConditions - ColourField property

Pre-requisite : Setup a basic Format Condition

Do you need to set the row font colour to be based on value returned from columns or fields? You can do so by making use of the ColourField property in FormatConditions (only available since Stadium 4.1.2280.5070). This property is similar to the ColourField property in TreeView node.

Scenario : Text colour for the 'Description' column is based on values returned from the 'Colour' column

Steps 
  1. Setup a format condition as follows :
  • Conditions - I am setting up a minimum condition so that it applies to ALL data  in the Grid
  • ColourField - The ColourField dropdown contains a list of Text type columns available in the Grid. Select the column which returns the value for colour. My selected column name is Colour.
Apply the format condition to the 'Description' column.


Results

View the application :

The FormatConditions is applied to the 'Description' column. You can see that the colour of the text is set to value from 'Colour' column in the same row.

Tips and Tricks
  1. If the value for ColourField property is defined, other Font Colour values will be overridden
  2. If the text returned from the field is invalid (not a valid colour), it will default to Black
  3. To apply format to all rows, you can set GreaterThanOrEquals '0' for Integer fields, and GreaterThanOrEquals 'a' for String fields.
  4. This property can be found in both DataGrid and DetailsView controls
  5. Only Text type columns are selectable in the ColourField dropdown list.

Global Format Conditions

Pre-requisite : View this post to setup basic FormatConditions.

The recent release of Stadium 4 includes a new feature, which is the Global Format Conditions. This feature allows you to define general Font properties which can then be used in Format Conditions editor. It reduces repetitive actions on applying the same format across different DataGrid or DetailsView columns. Here are some guidelines on how to use this new feature.

Quick step summary :
  1. Add and specify a global format condition in the FormatConditions node.
  2. Select the GlobalFormatCondition from the dropdown list in Format Conditions editor.
  3. Apply the format condition to the DataGrid column or DetailsView field.

Adding a GlobalFormatCondition

  1. Navigate to the FormatConditions node in your SAP file.
  2. Right-click on the FormatConditions node and click on “New Format Condition”. A new GlobalFormatCondition will be added.
  3. Change the Name from default "GlobalFormatCondition1" to “BoldRed”.

Specifying Font properties

  1. On the newly added "BoldRed" condition, expand “Font” property. You will see a list of properties.
  2. Specify the properties according to your requirements. In this scenario, I am setting it to “Bold” and “Red”.

Using GlobalFormatCondition

  1. GlobalFormatCondition can be used within the DataGrid and DetailsView Format Conditions editor.
  2. Open the Format Conditions editor and add a FormatCondition.
  3. Specify Conditions and select “BoldRed” from the GlobalFormatCondition dropdown list. You will notice that the Font properties are automatically populated with the GlobalFormatCondition values.
  4. Click OK.
  5. Link the FormatCondition to a column. The format will be applied to the column.
You can use the same GlobalFormatCondition in multiple DataGrid and DetailsView. Notice that you will not need to specify the same format repeatedly.



Required Field Validation for DropDown fields

In the recent release, we have included a required field validation for DropDown fields. This feature has only been added for the DetailsView control.

Property NameAllowed ValuesDescription
IsRequiredTrue/FalseSet to True if you want the field to be a required   field
IsRequiredInitialValueStringThis property is used to specify the initial value   for the field and compare if the field value has changed.
** Only valid if IsRequired   = True


This  post will teach you how to :
  • Setup required field validation for dropdown field
  • Changing value for selected text
Setting up Required Field validation
Step 1 : Add a DetailsView with DropDown field

Step 2 : Set IsRequired field property to ‘True’

Result :

  • A validation message is displayed when the ‘Save’ button is clicked.

Changing value for selected value in dropdown field
Step 1 : Set IsRequiredInitialValue to ‘I need to change this’

Result :

  • Selected value will be ‘I need to change this’
  • A validation message is displayed if user does not select a different value


Step 2 : Set IsRequiredInitialValue  property as blank

Result

  • Selected value will be blank

Additional information
  1. You cannot change the validation message.
  2. You can use Custom Setting / Page Parameter / System Variable / SQL Query to specify IsRequiredInitialValue text.
  3. If IsRequiredInitialValue is populated, DefaultValue will be overridden

Wednesday 15 May 2013

Stadium 4 Release: 4.1.2280.5070

Stadium 4.1.2280.5070 is available for download from the Twenty57 website. Please remember to back up your install folder before doing an upgrade. I know many people have edited the css for their chosen theme but the install will overwrite all files (except the web.config file and the configuration folder) to update them with any changes we have made. You can also rename your theme folder to something specific and change the Theme name in your web.config file to point to your 'custom' theme. The upgrade will not overwrite your renamed folder so your changes will not be lost. You will need to merge in any of the changes we have made that you want to make use of. You will need to upgrade your SAP files by opening them in the Designer, clicking Save and then refreshing them on the UI.

It is a bumper release and includes the following features:
  • ExecuteSQLCommand - Parameter Source None renamed to OutputToVariable
  • DisplayEmptyDataText is now a string rather than a Boolean Value so you can set your own message. Default is No data to display
  • The following properties can now be configured at a Global level for the Data Grid: Appearance>DataGrid
    • Column Wrap: Default True
    • Font Size: Default Empty (set from css)
    • Page Size: Default 20
    • Display Empty Data Text: Default No data to display
  • Set the font for a textbox
  • Break Tags are allowed in a label. This is the only HTML allowed
  • The UserApplicationRoleAccessRight view has been updated to include all user information
  • New Task on Site Roles: Assign Users to Site Roles. If checked a user assigned to the Site Role will be able to assign other users to Site Roles. For all existing Site Roles it is checked
  • Required Field Validation for Details View Dropdown. See . There are 2 new properties
    • IsRequired: Default is False
    • IsRequiredInitialValue: Default Please Select
    • If IsRequired is set to True then the first value in the Dropdown will be the Initial Value. The user will need to select a different value otherwise they will get a 'Required Field' message on Save
    • Any Default Value is overwritten in IsRequired is set to True
  • DataGrid Column Visible Property - Specify Condition option
  • Grid Iterator - Option to Auto Generate columns
  • Global Format Conditions Application Explorer>FormatConditions
    • Set the Font properties on a global level
    • On the control you will still need to specify the conditions (since these are usually Page and parameter specific) and select the Global Format from the Dropdown.
    • If you select a Global Format Condition you will not be able to set the Font for that specific Control Format Condition
  • Audit Logging of Users, Applications and Roles add, edit and delete
  • Hide the Stadium Header text on the Admin pages and login or change its value. You need to add the below attributes to the appSettings section of your web.config file. If you don't add them we will continue to display 'Stadium'
    • <add key="HideHeaderText" value="false" />
    • <add key="HeaderText" value="Stadium" />
  • Changes to the Forest Theme shades
  • Editable White space between the menu and the controls. You will need to change the default value in the css file for your theme to change this
    • Class: .MenuContainer
    • Property: margin-bottom: 12px;
  •  Format Conditions on Grid and Details View new property ColourField. It allows you to set the colour based on a value from one of your fields
  • Remember panel position when page is refreshed
  • Image Viewer alters the size of the panel not the image
    • Image with set width (in px) : The size of the image will not change. Only outer panel is resized. Viewing large images will have scroll bars.
    • Image with width (in %) : The size of panel will depend on image. Zooming in/out will not cause panel to resize.
    • Default width : The size of panel will depend on image.
And now for the significant change, Stadium 4 has been Upgraded to Report Viewer 2012 (version 11). We have tested a wide range of reports but please test your reports and let me know if any are not working. Please take note of the following:
  • Update your web.config file to reference Report Viewer 11 instead of 9. There are 2 places to account for different versions of IIS
    • In the HttpHandlers section replace the existing Report Viewer attribute with this one:
      • <add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    • In the  Handlers section replace the existing Report Viewer attribute with this one
      • <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
  • Microsoft Report Viewer 2012 runtime is required (http://www.microsoft.com/en-us/download/details.aspx?id=35747)
  • If you don't have SQL Server 2012 or 2008 R2 running, you can download the stand-alone report authoring tool, Report Builder 3.0 (http://www.microsoft.com/en-us/download/details.aspx?id=6116). This is the report builder application for both of these versions of SQL
    • Existing 2005 and 2008 rdls can be opened in Report Builder 3.0. A backup is automatically created for you and when you save the report it upgrades the format
    • Shared data sources have to be created on a reporting services 2008 R2 or 2012 server instance to make use of them in the tool. You cannot link to a shared data source saved elsewhere
    • You can specify a data source within the report that only exists for that report
  • Some 2005 and 2008 rdls do run in Report Viewer 2012 in local mode without requiring an upgrade. Others will give an error and need to be upgraded as described above
  • If you are running your reports in a Reporting Services instance and only viewing them in Stadium, Reporting services should take care of rendering any version of the rdl; 2012, 2008 R2, 2008 or 2005. Reporting services has a built-in 2005 report renderer
  • We have tested viewing reports running in Reporting Services 2008, Reporting Services 2008 R2 and Reporting Services 2012 instances.
Thank you to Ryan for all the development work and to Dina for all the Stadium knowledge and expertise she brings to the feature discussions as well as all the testing done!