Temporary sort a child table for reportbuilder export purposes destroys master-child link

Is it allowed to sort a child table that is master-child DA linked?
Is there a way to save/restore the required sort order?

We use reportbuilder to create reports of child data
When we do this (maybe specifically for excel exports ppLijstReport.DeviceType := dtXLSReport;)
we see that the master child link is broken (children are not displayed with correct master)

We have a generic routine that allows exports based on the sort order in the devexpress grid we use to display the DA tables.
We would need a generic solution.

Note: An extra inconvenience is that we cannot sort on calculated fields

FYI: Current sort code is
FTabel.Sort (Arr, SortArr);
with
Arr : Array of String;
SortArr : TDASortDirectionArray;

Hi,

Can you create a simple testcase w/o DevEx grid and ReportBuilder components that reproduces this issue with “the master child link is broken (children are not displayed with correct master)”, pls?

you can use “in memory” mode, when table.RemoteFetchEnabled = False

No, not really. The issue is a combination of remobjects, devexpress components and reportbuilder. Do you have all of these?

Hi,

sorting should work correctly with detail tables when std components are used.
if it don’t - then this is an issue. so I need a testcase to confirm that this doesn’t work as expected.
DevEx may perform sorting in incompatible mode.

Hi,

I assume it is the reportbuilder component
FYI: Printing does not give an issue, exporting to excel does however
Possibly because some dialogs are shown and the components get some processmessages during that time.

FYI:

  • I tried unlinking the mastersource but then I am missing the filter on the detail
  • I tried restoring the sort order but this crashes (in my case reverting to a sort with an empty array)
  • I tried creating a clone of the DATable but when doing that the calculated field I display does not get the correct value. Is there a generic DA table cloning routine?
    Note: Ideally the sort on a calculated field works after cloning

Should I send you some code snippets? How do we proceed?

Hi,

you can manually filter records after removing mastersource with Filter/Filtered

testcase for this case will be useful

are you using CloseSource feature?

  1. unlinking: It is a generic routine that has no idea about the master-detail relation
    Can give me generic code that does the filtering based on the master-detail link?
    I have added an attachment codesnippet.pas with some code fragments. How could I alter this code? Note: I believe this might not really be the issue and hence it isn’t the solution. I don’t know how much time we need to invest in this

  2. I have attached screenshots with the crash. They occur in RestoreSortSettings (see code snippet)

  3. I don’t know CloseSource, please show me some sample code.
    We clone via TDatasetUtils.AddRecords, the destination table was created via
    clonedTable := TXLSBaseDATableClass(Tabel.ClassType).Create(nil);

TXLSBaseDATable inherits from TOffBaseDATable which inherits from TDACDSDataTable

What is the best way of achieving this, ideally with possibility to sort on calculated fieldscodesnippet.pas (5.6 KB)

Hi,

Note: you are using TDACDSDataTable. this is legacy component for 7+ years so it wasn’t updated/tested with modern versions of Delphi and it may cause some issues with it.

you can review the ClonedSource sample:

This sample demonstrates usage of the clone source feature. This feature allows to create different presentation of data for tables. Each such presentation (or view) can have personal sorting, filtering and can be used in master/detail relationship.

  1. Yes, we have a giant codebase full of DA3 tables.
    I need a solution for both DA3 and DA4

  2. Where do I find the ClonedSource sample?

c:\Program Files (x86)\RemObjects Software>dir ClonedSource.* /s/b

File Not Found

all our samples are put to C:\Users\Public\Documents\RemObjects Samples.

this one is C:\Users\Public\Documents\RemObjects Samples\Data Abstract for Delphi\ClonedSource


TDAMemDataTable works correctly with DA3 style

Which RO server should I use?

I started the sample and it needs to connect to a RO server (http://localhost:7099/bin)
I have tried with DAServer from the same directory but I get a HTTP error

I looked at samples.html but I only see PCTrade under samples

-Frederic

you can use Relativity (standalone server) or DAServer (sample)

I tried DAServer from C:\Users\Public\Documents\RemObjects Samples\Data Abstract for Delphi\DAServer but that gives me the error from the screenshot.

I don’t know where to find Relativity

image

Hi,

Relativity can be found in RemObjects Data Abstract group inside start menu:
Untitled

pls extract this archive Simple db.zip (183.0 KB) into C:\Users\Public\Documents\RemObjects Samples\Database.
this will fix this case.

Untitled

Hello,

With the relativity server the sample works
I have examined it and see that this is a useful property for a permanent link.
To creating an excel export I only need a temporary link.
Do you still advise this method for my use case?
Do you find anything wrong in my clone code?

FYI: I will try your clone solution now

Hi,

The TDACDSDataTable class itself can be wrong. it uses some dirty hacking internally for accessing to internal FMasterLink: TMasterDataLink; property of TCustomClientDataSet.

so we don’t recommend to use it for new projects because it wasn’t tested with modern versions of Delphi.

FYI: Your solution appears to work, one thing that surprised me is that while exporting (the clone) i see the devexpress GUI component scroll over all items
I would have expected the clone cannot influence the source.
Can this be avoided?

Thanks for the help,
Frederic

Hi,

Clone source uses the same record set as main table, but it has own indexing, filtering, master source, record position, etc i.e. moving trough cloned table has no influence to main or other cloned tables. can you check that DevEx grid has another TDADataSource component than report builder?

Hi Evgeny I am affraid I have to retract my statement.
My code with CloneSource does not work
Contrary to your sample I create the clone programmatically
I use table.GetCloneSource()
but this returns nil
The remaining code reverts to a system where the grid datasource is used which is why I see the scrolling

Can you tell me what function i should use programmatically to create a clone?

Regards,
Frederic

Hi,
Check the ClonedSource (Console) sample:

lClonedTable:= TDAMemDataTable.Create(nil);
lClonedTable.CloneSource := lTable;
lClonedTable.Open;