0

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.

ulisses
  • 1,549
  • 3
  • 37
  • 85
  • If the calculated amount is calculated using existing table fields then this will help you http://stackoverflow.com/questions/11312013/is-it-possible-to-filter-a-datasource-getting-the-condition-from-a-calculated-fi – Pradeep Muttikulangara Vasu Feb 16 '17 at 00:21

1 Answers1

2

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!!

Numan Ijaz
  • 878
  • 1
  • 8
  • 18
  • 1
    Or you can use a view with a computed column (provided you can compute the value with SQL). https://msdn.microsoft.com/en-us/library/gg845841.aspx – Jan B. Kjeldsen Feb 16 '17 at 11:05