ASPxDashboard.CustomFilterExpression Event
Allows you to include WHERE clauses into DashboardSqlDataSource queries.
Namespace: DevExpress.DashboardWeb
Assembly: DevExpress.Dashboard.v18.2.Web.WebForms.dll
Declaration
Event Data
The CustomFilterExpression event's data class is CustomFilterExpressionWebEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
DashboardId | Gets the identifier of the current dashboard. |
DataSourceComponentName | Get the data source name, used in code to identify the data source’s object, for which the event has been raised. Inherited from CustomFilterExpressionEventArgs. |
DataSourceName | Gets the name of the data source for which the event has been raised. Inherited from CustomFilterExpressionEventArgs. |
FilterExpression | Gets or sets the filter expression that defines a WHERE clause included in the SQL query. Inherited from CustomFilterExpressionEventArgs. |
QueryName | Gets the name of the query for which the event was raised. Inherited from CustomFilterExpressionEventArgs. |
TableName | Indicates the name of a data table to which the CustomFilterExpressionEventArgs.FilterExpression applies. Inherited from CustomFilterExpressionEventArgs. |
Remarks
The CustomFilterExpression event fires for each SelectQuery within DashboardSqlDataSource (the SqlDataSource.Queries property) and allows you to include a WHERE clause to a query at runtime using the CustomFilterExpressionEventArgs.FilterExpression event parameter. If filtering is already applied to the SQL query, CustomFilterExpressionEventArgs.FilterExpression returns a corresponding filter criteria.
Note
The CustomFilterExpression event is not raised for custom SQL queries and stored procedures.
Example
The following example shows how to filter an SQL query at runtime using the ASPxDashboard.CustomFilterExpression
event. The CustomFilterExpressionEventArgs.TableName event parameter is used to check the name of the query that should be filtered. The CustomFilterExpressionEventArgs.FilterExpression property specifies the required filter criteria.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/aspxdashboard-how-to-filter-an-sql-query-at-runtime-t479085.
<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="WebForm1.aspx.vb"
Inherits="ASPxDashboard_CustomFilterExpression.WebForm1" %>
<%@ Register Assembly="DevExpress.Dashboard.v17.1.Web, Version=17.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0;">
<dx:ASPxDashboard ID="ASPxDashboard1" runat="server" Width="100%" Height="100%"
oncustomfilterexpression="ASPxDashboard1_CustomFilterExpression"
WorkingMode="Viewer">
</dx:ASPxDashboard>
</div>
</form>
</body>
</html>