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:
- 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
- You declare a DataView based on this DAC with no parameters.
In my Case it is PXSelect Details;
- Now you use DataView delegate to select other documents and create instances of your merged DAC on the fly.
- Finally you can bind the grid to the new DAC and show all required details.
- 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!