Search code examples
formsgridviewaxaptadynamics-ax-2012x++

How to hide record in Form grid based on display method value?


I have a simple Form, in my DataSource I created a classic displayMethod (named calculateAmount) and use this metodod to show the value in Form's grid.

So It's possible to show only record having a specific value from calculateAmount , for example I want to show only record having calculateAmount() > 0 , other record with calculated calculateAmount() < 0 not show.

So if I can't mix Query and displayMethod, possibly where I can insert the condition (for example active executeQuery etc) ?

Thanks in advice.


Solution

  • Consider the following sequence:

    1. Execute query is called and the AOT query is translated into SQL query
    2. Results are fetched from SQL server after executeQuery()
    3. Display method is called for each record and then the values are shown on grid

    So you cannot add query range on execute query based on display method value.

    One thing you can do:

    1. Duplicate your datasource table and set its Table Type property to TempDB
    2. In executeQuery method write the logic to fill this new created table
    3. Here you can add this condition like this:

      if ([your data source].calculateAmount() > 0) { // do not add the record in temp table } else { // add the record in temp table }

    4. Set your temp table as the datasource to your grid.

    Hope this helps!!