677181cadcca291d0c6591e9202faa5ad2a072ee
API/CodeSamples/HiddenCategories.md
| ... | ... | @@ -0,0 +1,86 @@ |
| 1 | +#HiddenCategories |
|
| 2 | + |
|
| 3 | +[[_TOC_]] |
|
| 4 | + |
|
| 5 | +##About |
|
| 6 | + |
|
| 7 | +Sets which categories are hidden for the current user. The category and any reports from those categories will not be shown to the current user in the report list or the report designer (when selecting a cateogry for the report). |
|
| 8 | + |
|
| 9 | +_**Note:** If a user with [[AllowCreateNewCategory|/API/CodeSamples/AllowCreateNewCategory]] set to true can type in the name of the hidden category and save a report to it, but when the user navigates back to the report viewer, the category and report will not be accessible anymore._ |
|
| 10 | + |
|
| 11 | +**Default Value:** empty list |
|
| 12 | + |
|
| 13 | +##Global.asax (C♯) |
|
| 14 | + |
|
| 15 | +```csharp |
|
| 16 | +//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 17 | +public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig |
|
| 18 | +{ |
|
| 19 | + // Configure settings |
|
| 20 | + // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method |
|
| 21 | + public static void InitializeReporting() { |
|
| 22 | + //Check to see if we've already initialized. |
|
| 23 | + if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 24 | + return; |
|
| 25 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"; |
|
| 26 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"; |
|
| 27 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig(); |
|
| 28 | + AdHocSettings.HiddenCategories = new string[] {"Admin Reports", "Restricted Logs"}; //The relevant setting |
|
| 29 | + HttpContext.Current.Session["ReportingInitialized"] = true; |
|
| 30 | + } |
|
| 31 | +} |
|
| 32 | +``` |
|
| 33 | + |
|
| 34 | +##Global.asax (VB.NET) |
|
| 35 | + |
|
| 36 | +```visualbasic |
|
| 37 | +'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 38 | +Public Class CustomAdHocConfig |
|
| 39 | + Inherits Izenda.AdHoc.DatabaseAdHocConfig |
|
| 40 | + |
|
| 41 | + Shared Sub InitializeReporting() |
|
| 42 | + 'Check to see if we've already initialized |
|
| 43 | + If HttpContext.Current.Session Is Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then |
|
| 44 | + Return |
|
| 45 | + 'Initialize System |
|
| 46 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE" |
|
| 47 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE" |
|
| 48 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = New CustomAdHocConfig() |
|
| 49 | + AdHocSettings.HiddenCategories = new string() {"Admin Reports", "Restricted Logs"}; 'The relevant setting |
|
| 50 | + HttpContext.Current.Session("ReportingInitialized") = True |
|
| 51 | + End Sub |
|
| 52 | +End Class |
|
| 53 | +``` |
|
| 54 | + |
|
| 55 | +##Screenshots (legacy report list) |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + |
|
| 59 | +##Screenshots (modern report list) |
|
| 60 | + |
|
| 61 | +Below: The user is "admin" and there are no hidden categories for this user. |
|
| 62 | + |
|
| 63 | +```csharp |
|
| 64 | +AdHocSettings.CurrentUserName = "admin"; |
|
| 65 | +AdHocSettings.CurrentUserIsAdmin = true; |
|
| 66 | +AdHocSettings.HiddenCategories = new string[0]; //nothing hidden |
|
| 67 | +``` |
|
| 68 | + |
|
| 69 | +![]() |
|
| 70 | + |
|
| 71 | +Below: The user is "user" and the "base" category from above is hidden. |
|
| 72 | + |
|
| 73 | +```csharp |
|
| 74 | +AdHocSettings.CurrentUserName = "user"; |
|
| 75 | +AdHocSettings.HiddenCategories = new string[] {"base"}; //base is hidden |
|
| 76 | +``` |
|
| 77 | + |
|
| 78 | +##Screenshots (report designer) |
|
| 79 | + |
|
| 80 | +Below: the user is "admin" and can add reports to the "base" category |
|
| 81 | + |
|
| 82 | +![]() |
|
| 83 | + |
|
| 84 | +Below: The user is "designer" and cannot see the "base" category in the designer |
|
| 85 | + |
|
| 86 | +![]() |
|
| ... | ... | \ No newline at end of file |