Using filters in drop-down lists
When using objects as report parameters, you may need to filter the object instances. For example, when using the Project object as the parameter, the drop-down list will include active, draft and archived projects.
To filter data in the drop-down list of such a parameter, open the Display Settings tab of the report, select The form is defined by the user (.NET Razor) and go to the tab.
By default, the page is empty. Use the Template Wizard to generate the parameter markup, which looks like this:
@using EleWise.ELMA.BPM.Web.Reports.Extensions
@using System.Data
@model EleWise.ELMA.BPM.Web.Reports.Models.ReportParametersInfo
<style>
.list th {
background: none repeat scroll 0 0 #666666;
color: #FFFFFF;
padding: 5px;
text-align: left;
}
.list td {
border-bottom: 1px solid #CCCCCC;
padding: 3px 5px;
vertical-align: middle;
}
</style>
<table style="width:100%" class="listTaskExec">
@Html.EditorFor(m => m.Parameters)
</table>
At the end of the markup, you can see these lines:
<table style="width:100%" class="listTaskExec">
@Html.EditorFor(m => m.Parameters)
</table>
@Html.EditorFor(m => m.Parameters)
Displays all the parameters on the form.
Add this namespace:
@using EleWise.ELMA.Web.Mvc.Html
Describe the output of each parameter in particular, delete @Html.EditorFor(m => m.Parameters)
и заменим на:
@Html.EditableProperty("Parameters.Executor")
@Html.EditableProperty("Parameters.Project")
@Html.EditableProperty("Parameters.Status")
Where Parameters.Name – is the name of the required parameter
Now you can configure these parameters as necessary, e.g. to display only active projects, add:
@Html.EditableProperty("Parameters.Project", a => a.TypeSettingsAction = s => ((EleWise.ELMA.Model.Types.Settings.EntitySettings)s).FilterQuery = "Status = Enum(’Active’)")
Where FilterQuery – is an EQL query. To learn more about EQL, read this article.
The markup will look like this:
@using EleWise.ELMA.BPM.Web.Reports.Extensions
@using System.Data
@using EleWise.ELMA.Web.Mvc.Html
@model EleWise.ELMA.BPM.Web.Reports.Models.ReportParametersInfo
<style>
.list th {
background: none repeat scroll 0 0 #666666;
color: #FFFFFF;
padding: 5px;
text-align: left;
}
.list td {
border-bottom: 1px solid #CCCCCC;
padding: 3px 5px;
vertical-align: middle;
}
</style>
<table style="width:100%" class="listTaskExec">
@Html.EditableProperty("Parameters.Executor")
@Html.EditableProperty("Parameters.Project", a => a.TypeSettingsAction = s => ((EleWise.ELMA.Model.Types.Settings.EntitySettings)s).FilterQuery = "Status = Enum(’Active’)")
@Html.EditableProperty("Parameters.Status")
</table>
This way you can filter instances of any objects: contractors of a specific category, tasks of a certain user, approved documents, etc.