Jun 22, 2010

Filtering Enterprise Portal, the difference between UserFilter and standard ranges

Today I discovered a subtle, but important, difference between the two of the filtering methods we can use in Enterprise Portal 2009.

Given the following two sections of code in the Page_Load method of the ASP.NET code behind, and given the following:

String TID = this.Page.Request.QueryString.Get("TID");
//Method 1 or Method 2 here.

Method 1: UserFilter

DataSetView dsv = this.AxDataSource1.GetDataSet().DataSetViews[0];
filterObject flt = new filterObject();

flt.name = "TIDFilter";

conditionType cndId = new conditionType();
cndId.@operator = operatorType.eq;
cndId.status = conditionStatus.open;
cndId.attribute = "TrvId";
cndId.value = TID;

flt.conditionCollection.Add(cndId); //add to filter

Method 2: Standard Ax QueryBuildRange filter

DataSetView dsv = this.AxDataSource1.GetDataSet().DataSetViews[0];

Proxy.Query query = dsv.MasterDataSource.query();
Proxy.QueryBuildRange qbr = query.dataSourceNo(1).findRange(TableDataFieldMetadata.FieldNum(this.AxSession, "AdTrvTable", "TrvId"));
if (qbr == null)
qbr = query.dataSourceNo(1).addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "AdTrvTable", "TrvId"));
qbr.value = TID;

Both of these methods do what you want: They both apply a filter to your Web Grid and displays the data you are interested in.

BUT, and this is an important but, the standard Ax QueryBuildRange limits the datasource to only the records you are interested in. The UserFilter on the other hand merely hides the remaining records, to be available for AJAX lookups and such should the need arise.

If you are dependent on only having the appropriate records in your datasource you should use QueryBuildRange.

If you are displaying different subsets of the datasource at different times you should use a UserFilter to reduce the number of server queries.

No comments:

Post a Comment