Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to filter data on the server side with XtraReports Parameters

$
0
0

The criteria you specify in the XtraReport.FilterString property is applied to data source rows by the report control on the client side by default. When working with large data sets, it makes sense to apply this filter directly to the data source to avoid excessive data transfer. This task can be accomplished by creating the following scripts in the report:

[C#]
privatevoidxafReport1_BeforePrint(objectsender,System.Drawing.Printing.PrintEventArgse){DevExpress.Data.Filtering.OperandValue[]prameterOperands;DevExpress.Data.Filtering.CriteriaOperatorcriteria=DevExpress.Data.Filtering.CriteriaOperator.Parse(xafReport1.FilterString,outprameterOperands);foreach(DevExpress.Data.Filtering.OperandValuetheOperandinprameterOperands){DevExpress.Data.Filtering.OperandParameteroperandParameter=theOperandasDevExpress.Data.Filtering.OperandParameter;if(!object.ReferenceEquals(operandParameter,null)){DevExpress.XtraReports.Parameters.Parameterparam=xafReport1.Parameters[operandParameter.ParameterName];if(param!=null)operandParameter.Value=param.Value;}}DevExpress.ExpressApp.Reports.XafReportxafReport=(DevExpress.ExpressApp.Reports.XafReport)xafReport1;IListoriginalDataSource=xafReport.ObjectSpace.GetObjects(xafReport.DataType,criteria);xafReport1.DataSource=newDevExpress.ExpressApp.ProxyCollection(xafReport.ObjectSpace,DevExpress.ExpressApp.XafTypesInfo.Instance.FindTypeInfo(xafReport.DataType),originalDataSource);}privatevoidxafReport1_DataSourceDemanded(objectsender,System.EventArgse){xafReport1.DataSource=null;}

Question Comments

Added By: Gustavo Marzioni at: 4/2/2013 12:10:16 PM    

Why this funcionality, that is very important is not included in XafReport??

Added By: Ken Gliddon at: 2/10/2014 10:39:38 PM    

Please help with this report parameters. If I add it to the script the parameters panel on the report shows yet when select a parameter it generates the SQL query which fails saying Conversion failed when converting from character string to uniqueidentifier, the parameter sample seems to fail when using the Oid from the selected paramters

Added By: Adrian D Ilie at: 2/16/2014 12:04:24 AM    

What happens if a parameter is a non-persistent property, which cannot be automatically translated into a SQL query for server filtering? A simple example: a non-persistent IsActive property that looks at two persistent properties, StartDate and EndDate, and returns true if today's date falls between them, or EndDate is null. Filtering by IsActive is performed on the client, correct? Is filtering by other criteria, which do not rely on non-persistent properties, performed automatically on the server? I ask because I can, with some effort, translate the algorithm that computes the non-persistent property into a script that creates the same condition but relies exclusively on persistent properties, which can be filtered on the server. This effort would be worth my time if having a single non-persistent property causes filtering to be performed on the client, without taking advantage of the other persistent properties which can be filtered on the server.

Added By: Gustavo Marzioni at: 11/24/2015 6:48:51 AM    

I have to use it in DataSourceDemanded not in BeforePrint, because it don't work for child collections


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>