Want to turn you're data into a true asset? Ready to break free from the report factory? Ready to gain true insights that are action focused for truly data informed decisions? Want to do all of this across mutliple companies, instances of Dynamics and your other investments? Hillstar Business Intelligence is the answer then! (www.HillstarBI.com)

Let us prove to you how we can take the complexity out of the schema and truly enable users to answer the needed questions to run your business! Visit Hillstar Business Solutions at: www.HillstarBI.com

About Me

Friday, April 27, 2007

DAX 4.0 Filter by Grid [Update]

Well take a look at this:"bskiles has left a new comment on your post "Filter by Grid in DAX 4.0": I [bskiles] was trying to figure out how to turn the "Filter by Grid" on in code, and I figured it out. Call the .task method on the form with a parameter of 2855 after the grid is selected. Anything that extends FormRun can make the call to .task(2855). Unfortunately, I can't trace it back up to FormRun since that's a system object. I'm still interested in learning how it actually works so that I can set it up as a user setting per grid. "

It's a comment from my blog entry here: Filter by Grid - Older Post bskiles took the time and was able to find how to actually call the Filter by Grid from code! Very nice work! It's strange that it's such a hidden event / call? Anyway just wanted to report this find, thanks bskiles!

10 Comments:

Just tried this myself though and have tried a couple of different places for the call to .task(2855) and no joy :(

My scenario is a form launched when creating a new record (so just like creating a new sales order). In the forms run event, I call lookup on my main field to show it's search popup. In a live environment my users will always need the help of the filter to find the record they're after so this feature would be very nice to automate the filter rather than clicking the toolbar icon each time. (further ideas involve turning this on for all grids in the system or storing per user whether to have it on or off per grid like bskiles is hoping to do).

Any chance either yourself or bskiles could follow up with a short example? Thanks

Sorry for the delay in responding, I got busy and didn't get a chance to follow up for a while.

Here is a quick example for the form PurchTable. I put the code at the end of the Run method. The grid "Grid" needs to be set to autodeclaration = true.

Grid.enter(); this.task(2855);

And that's it!

Unfortunately, that doesn't help much if you wish to implement this system-wide, which is what I would like to do.

SysSetupFormRun seems like the correct place to set this up. I've overriden the "Run" method. So far the code looks something like this:void run() { super(); // insert good code here! // find a grid to enter! this.task(2855);}

There is a major problem with this code, though! In some cases the call to task causes Axapta to crash. For some users it happens for every form. I haven't yet found the root cause. If you manage to fix the crash problem, please share! I suspect that my code to find and enter a grid is failing.

I initially had that PurchTable crash Dynamics on me so I broke it down to see which of the two lines was causing the grief (and hopefully why).

When the form loads as 'simple', the grid is not visible but the Grid.enter() shows it in a skeleton form (just the outline). If this happens, the this.task... line crashes AX. This might be a pointer as to why it sometimes crashes elsewhere.

So far (in 20 mins of playing!), the following run method is stable however I leave the form:

void run(){

super();

if (!advanced) tabHeader.tab(2); else { tabHeader.tab(1);

Grid.enter(); this.task(2855); }}(extra code also required though when the overview tab becomes the current tab as changing from simple to advanced doesn't show the filter).

One of my longterm goals is to get the filter to show on an automatic lookup grid. If I manage that or anything else in this area I'll post back.

Here is the source code for my latest attempt. I simply turn on the "filter by grid" for the first visible grid on the form. Someone could probably spend some time to make it a configurable option per form, but that's left as an exercise to the person who would like to do that. I've not received a crash in my testing thus far.

I've modified the SysSetupFormRun class. I overrode the method Run and added two other methods to find the top-level grid. FindGrid has some room for improvement. I'd hoped to use a FormBuildControl and the IsContainer method to handle iteration, but couldn't figure that one out. The documentation is a bit sparse. I'm interested in seeing any improvements people make to this bit of code.

Upon preview, it appears that my nice indentation is stripped out. I really did indent my code in a sane way!

Hi, I found this topic from Google and I'm little bit late...but still I have a question. Do you think it's possible to change which filter type is used by default? I'd like to use 'contains' type by default. Thanks for answering.

just a comment about the Filter by Grid feature. it seems to cause a performance problem on those grids which have significant amount of data. the grid seems to refresh several times when you move from one row to another.