Total Pageviews

Search This Blog

Wednesday, March 20, 2013

Applying Custom filters to Dynamics AX Enterprise Portal Grid

Dear All,

Hope you are doing well. 

Recently, I did an Enterprise Portal code upgrade for one of my customers. They are on Dynamics AX 2009 and as I was investigating, I found that the web forms of Dynamics AX 4.0 were not upgraded by their previous vendor, so I undertook the  task of  upgrading their 20+ web forms (Dynamics AX 4.0) to Dynamics AX 2009 web controls. 

I had to replace the existing standard filters which comes with EP AxGridView to custom textbox filters. And, for this reason I had to apply the filters via code. I got a good idea by seeing this useful blog on how to achieve it http://blogs.msdn.com/b/epblog/archive/2008/11/17/filtering-a-dataset-from-code-behind.aspx

There was a small hiccup while referencing FilterCondition and Typ as I didn't knew the namespace, so before we use the filterObject and conditionType objects, dont forget to declare the below highlighted namespace.

using Microsoft.Dynamics.Framework.Data.Ax;

Microsoft.Dynamics.Framework.Data.Ax.filterObject
Microsoft.Dynamics.Framework.Data.Ax.conditionType



2 comments:

Anonymous said...

Hello,

Very useful post.

What is the syntax to identify one the dimension field:
typ.attribute = "Dimension[3]"

returns an error, same with other variations:
Dimension3_
Dimension3
Dimension_3

There must be a way to use one of the dimension field.

We're on Ax 2009 (until September!)

Regards,

Donatas said...

The namespace has changed from to "using Microsoft.Dynamics.AX.Framework.Portal.Data;".

So the code itself will look as following:
dsv.UserFilter.ClearOpenFilter();
filterObject flt = new filterObject();
flt.name = "NameFilter";
conditionType typ = new conditionType();
typ.__operator = operatorType.like;
typ.status = conditionStatus.open;
typ.value = lb.Text;
typ.attribute = "Name";
flt.conditionCollection.Add(typ);
dsv.UserFilter.Add(flt);