Wednesday, 30 September 2015

Using Virtual Data Access Class

Sometimes you want to show existing data in the different format (for report, inquire or corporation purpose).
In my example I want to show you how to transform transform database table into something different. I have a table with years, groups and values, I want to group data by year and compare it between selected years.



To do this we will use data view delegates and virtual data access classes.
First of all lets define 3 data access classes:

  • YearGroup - DAC for selecting data from database table.
  • YearFilter - virtual DAC for storing year what we want to compare.
  • VirtualComparasion - virtual DAC for showing grouped data in UI.
Code:

Now we need to define logic. The main idea here, that we can use data view delegate to select and process the data. But also we can store prepared data in the PXCache, so we don't need to process it on every callback. It will make performance of our screen faster.
Also please notice, that we can clear cached data on filter update, so system will recalculate compared data on next callback.

Code:

Result:

No comments: