feb2076a81eb839804b77a48f36f7be6c583782e
FAQ/Questions/How-To-Preset-Values-In-Filter.md
| ... | ... | @@ -43,6 +43,37 @@ You can use hidden filter to make reports pre-filtered whenever they are opened |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | ``` |
| 46 | + |
|
| 47 | + |
|
| 48 | +##Global.asax (VB.Net) |
|
| 49 | +```visualbasic |
|
| 50 | +Public Overrides Sub PreExecuteReportSet(reportSet As ReportSet) |
|
| 51 | + MyBase.PreExecuteReportSet(reportSet) |
|
| 52 | + |
|
| 53 | + ' if (reportSet.ReportName != "MyReport" || reportSet.ReportName != "MyReport2") // You can choose to which report this overriding to be applied |
|
| 54 | + ' return; |
|
| 55 | + |
|
| 56 | + For Each filter As Izenda.AdHoc.Filter In reportSet.Filters |
|
| 57 | + |
|
| 58 | + If filter.[Operator] = OperatorTypes.BetweenTwoDates Then |
|
| 59 | + ' can choose filter as well based on its operator |
|
| 60 | + If filter.dbColumn.Name.Equals("OrderDate") Then |
|
| 61 | + ' To be applied to "OrderDate" filter |
|
| 62 | + Dim baseDate As DateTime = DateTime.Today |
|
| 63 | + |
|
| 64 | + filter.Values.SetValue(baseDate.AddYears(-1), 0) |
|
| 65 | + 'the'Between' operator takes two parameters. the first one's indexed as 0. '-1' for a year ago |
|
| 66 | + |
|
| 67 | + ' reportSet.Filters[count].Values.SetValue("01/01/2010", 1); |
|
| 68 | + ' reportSet.Filters[count].Values.SetValue("01/01/2016", 1); // the date value could be a specific date |
|
| 69 | + |
|
| 70 | + filter.Values.SetValue(DateTime.Today, 1) |
|
| 71 | + End If |
|
| 72 | + End If |
|
| 73 | + Next |
|
| 74 | +End Sub |
|
| 75 | + |
|
| 76 | +``` |
|
| 46 | 77 | ##Screenshots |
| 47 | 78 | |
| 48 | 79 |  |