2b2601c92aa8d7a9793f8af9c980a9db21416661
API/CodeSamples/FilterAliases.md
| ... | ... | @@ -0,0 +1,76 @@ |
| 1 | +#FilterAliases |
|
| 2 | + |
|
| 3 | +[[_TOC_]] |
|
| 4 | + |
|
| 5 | +##About |
|
| 6 | + |
|
| 7 | +Gets or sets the Filter names(aliases) that the user sees in the Report Designer, Report Viewer, and Dashboards. This can be set globally or on a per-user basis. The key is the name of your column in the database and the value is the alias you wish the user to see. This is useful for localization and when custom filters are used in your application. |
|
| 8 | + |
|
| 9 | +Below is a sample global.asax using the ExtendedFunctions setting. The code block will appear within ``<script runat="server"> </script>`` tags within global.asax. |
|
| 10 | + |
|
| 11 | +##Global.asax (C♯) |
|
| 12 | + |
|
| 13 | +```csharp |
|
| 14 | +//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 15 | +public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig |
|
| 16 | +{ |
|
| 17 | + // Configure settings |
|
| 18 | + // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method |
|
| 19 | + public static void InitializeReporting() { |
|
| 20 | + //Check to see if we've already initialized. |
|
| 21 | + if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 22 | + return; |
|
| 23 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"; |
|
| 24 | + //Creates a connection to Microsoft SQL Server |
|
| 25 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"; |
|
| 26 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig(); |
|
| 27 | + AdHocSettings.FilterAliases["ShipCity"] = "DepartureCity"; //The relevant setting |
|
| 28 | + HttpContext.Current.Session["ReportingInitialized"] = true; |
|
| 29 | + } |
|
| 30 | +} |
|
| 31 | +``` |
|
| 32 | + |
|
| 33 | +##Global.asax (VB.NET) |
|
| 34 | + |
|
| 35 | +```visualbasic |
|
| 36 | +'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 37 | +Public Class CustomAdHocConfig |
|
| 38 | + Inherits Izenda.AdHoc.DatabaseAdHocConfig |
|
| 39 | + |
|
| 40 | + Shared Sub InitializeReporting() |
|
| 41 | + 'Check to see if we've already initialized |
|
| 42 | + If HttpContext.Current.Session Is Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then |
|
| 43 | + Return |
|
| 44 | + 'Initialize System |
|
| 45 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE" |
|
| 46 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE" |
|
| 47 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = New CustomAdHocConfig() |
|
| 48 | + AdHocSettings.FilterAliases("ShipCity") = "DepartureCity" 'The relevant setting |
|
| 49 | + HttpContext.Current.Session("ReportingInitialized") = True |
|
| 50 | + End Sub |
|
| 51 | +End Class |
|
| 52 | +``` |
|
| 53 | + |
|
| 54 | +##Fully-qualified column names |
|
| 55 | + |
|
| 56 | +You can use fully-qualified column names to allow columns from different tables and schemas with the same name to be aliased differently if you so desire. To do that, simply use bracket notation to specify the schema and table: |
|
| 57 | + |
|
| 58 | +```csharp |
|
| 59 | +AdHocSettings.FilterAliases.Add("[dbo].[Orders].[ShipCity]", "DepartureCity"); |
|
| 60 | +``` |
|
| 61 | + |
|
| 62 | +###Screenshots |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + |
|
| 66 | +###Alias Filter Field Names |
|
| 67 | + |
|
| 68 | +The filter field name can be aliased using the Description field. This can be accessed in the Report designer from the filter tab or from the viewer by clicking the gear icon in the filter. |
|
| 69 | + |
|
| 70 | +Here the Description can be entered in the Report Designer's Filter Tab. |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + |
|
| 74 | +And here is the description field in the Report Viewer by clicking the gear icon on the filter. |
|
| 75 | + |
|
| 76 | + |
|
| ... | ... | \ No newline at end of file |