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;
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
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.
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?
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
I have attached screenshots with the crash. They occur in RestoreSortSettings (see code snippet)
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)
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.
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
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?
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?
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?