Back to Devexpress

DashboardViewer.CustomFilterExpression Event

dashboard-devexpress-dot-dashboardwin-dot-dashboardviewer-9f1c6700.md

latest5.6 KB
Original Source

DashboardViewer.CustomFilterExpression Event

Allows you to include WHERE clauses into DashboardSqlDataSource queries.

Namespace : DevExpress.DashboardWin

Assembly : DevExpress.Dashboard.v25.2.Win.dll

NuGet Package : DevExpress.Win.Dashboard

Declaration

csharp
public event CustomFilterExpressionEventHandler CustomFilterExpression
vb
Public Event CustomFilterExpression As CustomFilterExpressionEventHandler

Event Data

The CustomFilterExpression event's data class is CustomFilterExpressionEventArgs. The following properties provide information specific to this event:

PropertyDescription
DataSourceComponentNameGet the data source name, used in code to identify the data source’s object, for which the event has been raised.
DataSourceConnectionName
DataSourceNameGets the name of the data source for which the event has been raised.
FilterExpressionGets or sets the filter expression that defines a WHERE clause included in the SQL query.
QueryNameGets the name of the query for which the event was raised.

Remarks

The CustomFilterExpression event fires for each SelectQuery within the SqlDataSource.Queries collection. The e.FilterExpression property allows you to include a WHERE clause into a query at runtime. If a filter is already applied to the SQL query, e.FilterExpression returns the corresponding filter criteria.

For more information on how to create filter criteria as a CriteriaOperator object, refer to the following help article: Simplified Criteria Syntax.

Note

The CustomFilterExpression event is not raised for custom SQL queries and stored procedures.

Example

Note

This example demonstrates API and functionality that is common for the DashboardViewer and DashboardDesigner controls.

This example shows how to handle the DashboardViewer.CustomFilterExpression event to filter an SQL query at runtime. The e.QueryName event parameter is the query name. The e.FilterExpression property specifies the filter criteria.

View Example

csharp
using DevExpress.DataAccess;
using DevExpress.Data.Filtering;

namespace Dashboard_CustomFilterExpression_Win {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm {
        public Form1() {
            InitializeComponent();
            dashboardViewer1.LoadDashboard(@"..\..\Data\Dashboard.xml");
        }

        private void dashboardViewer1_CustomFilterExpression(object sender, CustomFilterExpressionEventArgs e) {
            if (e.DataSourceName == "SQL Data Source 1" && e.TableName == "Invoices") {
                e.FilterExpression = new BinaryOperator("CustomerID","AROUT",BinaryOperatorType.Equal);
            }
        }
    }
}
vb
Imports DevExpress.DataAccess
Imports DevExpress.Data.Filtering

Namespace Dashboard_CustomFilterExpression_Win
    Partial Public Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

        Public Sub New()
            InitializeComponent()
            dashboardViewer1.LoadDashboard("..\..\Data\Dashboard.xml")
        End Sub

        Private Sub dashboardViewer1_CustomFilterExpression(ByVal sender As Object, ByVal e As CustomFilterExpressionEventArgs) Handles dashboardViewer1.CustomFilterExpression
            If e.DataSourceName = "SQL Data Source 1" AndAlso e.TableName = "Invoices" Then
                e.FilterExpression = New BinaryOperator("CustomerID","AROUT",BinaryOperatorType.Equal)
            End If
        End Sub
    End Class
End Namespace

Implements

CustomFilterExpression

See Also

ConfigureDataConnection

DashboardViewer Class

DashboardViewer Members

DevExpress.DashboardWin Namespace