Select Multiple Documents into One Grid

Hi Everyone,

In some situations you may want to show different unconnected documents inside one grid.
Just for example you want to create Customer Overview screen and show all Invoices, Payments and Sales Orders together in one place.

Join tables together is not the best approach, as you will have to add different columns with same names for fields from different tables.
Better Approach is select them independently in Data View delegate and merge them into one virtual DAC.
So plan is the following:

  1. Create a new Virtual DAC that will represent any document in the system. Please note that this DAC should have a Key that should unique even if there a several documents with the same number in different modules. Usually you can just add a Module to DAC key.
    In my example this DAC is AnyDocument
  2. You declare a DataView based on this DAC with no parameters.
    In my Case it is PXSelect Details;
  3. Now you use DataView delegate to select other documents and create instances of your merged DAC on the fly.
  4. Finally you can bind the grid to the new DAC and show all required details.
  5. If you want to have a navigation, you need to implement a special navigation action and there depend on Module decide what Graph should you use for redirection purpose.

Here you can see the full example of the CustomerOverview graph:

Couple of important things in this example:
– PXVirtualDAC – Is a special PXCache extension that forbid cache to read the database in any case. we need it as this DAC is virtual.
– CustomerFamilyHelper – is needed to get parent child relationship to select all the documents from child customers also.
– IsDirty – we override this method to no not notify users that they need to save changes before they leave the screen.
– PXRedirectRequiredException – does actual navigation.

Have a nice development!

3 Replies to “Select Multiple Documents into One Grid”

  1. Hi Sergey,

    Great post. This can be very useful in certain situations.
    My instinct would have been to create some database view but this is definitely better. I was not aware of the Virtual DAC.
    If I understood correctly, it might be difficult to support database paging using above approach. When retrieving invoices, payments, etc. But this should not be an issue in most cases.


Leave a Reply

Your email address will not be published. Required fields are marked *