FAQ/Questions/setting-defaults-for-report-designer.md
... ...
@@ -0,0 +1,57 @@
1
+#Setting Defaults for the Report Designer
2
+
3
+[[_TOC_]]
4
+
5
+##Question
6
+
7
+How can I set default report designer options that are not standard with Izenda for my customers? If I want the report designer to initialize with certain datasources already selected or certain report options enabled, how would I do that?
8
+
9
+##Answer
10
+
11
+In order to change the default report designer options, such as datasources, fields, filters, or other options, the underlying CurrentReportSet must be modified. The CurrentReportSet controls which report is currently loaded, and exists even when the report designer initializes a new ReportSet. In order to detect that the ReportSet contained within CurrentReportSet is new, simply check the ReportName property in the OnPreLoad() method of the ReportDesigner.aspx.cs file. An example of this can be seen below.
12
+
13
+```csharp
14
+protected override void OnPreLoad(EventArgs e)
15
+{
16
+ try
17
+ {
18
+ string name = AdHocContext.CurrentReportSet.ReportName;
19
+ }
20
+ catch // this is new report
21
+ {
22
+ //Perform any report designer behavior changes in here
23
+ }
24
+}
25
+
26
+###Adding datasources
27
+
28
+You may want to start all users who navigate to the report designer with a default datasource. In order to accomplish this, insert the code template below into your code.
29
+
30
+```csharp
31
+if(AdHocContext.CurrentReportSet.JoinedTables.Count == 0)
32
+ AdHocContext.CurrentReportSet.JoinedTables.Add(new JoinedTable { TableName = "[dbo].[Orders]" });
33
+```
34
+
35
+Adding multiple tables with relationships is accomplished by performing the above step, plus adding additional tables with valid join relationships. Izenda will automatically check to ensure the tables and columns exist at runtime.
36
+
37
+###Adding fields
38
+
39
+In order to add any fields, you will need to access the underlying "Detail" report within the CurrentReportSet object and a valid datasource must be added as discussed above.
40
+
41
+```csharp
42
+AdHocContext.CurrentReportSet.Detail.Fields.Add(new Field("[dbo].[Orders].[ShipCountry]"));
43
+```
44
+
45
+###Changing default report options
46
+
47
+You may want to adjust options that apply to the style of the report, such as the Visual Group style, whether the date and time are displayed in the report header for exports, or whether pagination is turned on by default. To accomplish these and other related actions, use code that accesses the corresponding property on the CurrentReportSet object.
48
+
49
+```csharp
50
+//Default Visual group style
51
+AdHocContext.CurrentReportSet.VisualGroupStyle = VisualGroupStyle.LineDelimited;
52
+//Show date and time on exports by default
53
+AdHocContext.CurrentReportSet.ShowDateTime = true;
54
+//Enable pagination by default
55
+AdHocContext.CurrentReportSet.UsePaginationInWebView = true;
56
+```
57
+