Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TFDMemTable Nested Dataset not sorting via IndexFieldNames


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Feb 14, 2017 11:58 AM Last Post By: Dan Palley
Dan Palley

Posts: 43
Registered: 2/14/00
TFDMemTable Nested Dataset not sorting via IndexFieldNames  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 8, 2017 10:02 AM
I have some code that is using TClientDataset that I'm migrating to TFDMemTable. So far, things have been smooth, but I'm running into an issue with sorting.

I have a TFDMemTable that contains various nested datasets. I iterate through the nested datasets and append records as needed. To make sure there are no dupes, I set the nested dataset's indexfieldnames to the primary key and then search for the key using GotoKey. I'm running into cases where the dataset is not sorted correctly, so GotoKey fails. Here's some sample code:

ChildDS:=TFDMemTable(TDatasetField(ParentDS.FieldByName(ChildDSName)).NestedDataSet);
ChildDS.IndexFieldNames:=ChildDSIndexFieldName;
ChildDS.SetKey;
ChildDS.FieldByName(ChildDSIndexFieldName).Value:=KeyValue; // KeyValue points to an existing record in ChildDS
if not ChildDS.GotoKey then
Raise Exception.Create('Key not found');

I suspect there's a problem with the first line where I cast the Nested Dataset to a TFDMemTable. This code works with TClientDataset. Is there another way I can get the nested dataset as a TFDMemTable?

Thanks,

Dan Palley
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: TFDMemTable Nested Dataset not sorting via IndexFieldNames  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 9, 2017 12:22 PM   in response to: Dan Palley in response to: Dan Palley
It has to work. If does not, then it is a bug. You can register it at Embt Quality Portal.

--
With best regards,
Dmitry
Dan Palley

Posts: 43
Registered: 2/14/00
Re: TFDMemTable Nested Dataset not sorting via IndexFieldNames  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 9, 2017 5:35 PM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
It has to work. If does not, then it is a bug. You can register it at Embt Quality Portal.

--
With best regards,
Dmitry

Hi Dmitry, I found that using FindKey, instead of GotoKey, does work. I'll see if I can create a small sample project and load it to Quality Portal.

Thanks,

Dan
Dan Palley

Posts: 43
Registered: 2/14/00
Re: TFDMemTable Nested Dataset not sorting via IndexFieldNames  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 14, 2017 11:48 AM   in response to: Dan Palley in response to: Dan Palley
Dan Palley wrote:
Dmitry Arefiev wrote:
It has to work. If does not, then it is a bug. You can register it at Embt Quality Portal.

--
With best regards,
Dmitry

Hi Dmitry, I found that using FindKey, instead of GotoKey, does work. I'll see if I can create a small sample project and load it to Quality Portal.

Thanks,

Dan

Hi Dmitry,

I've created a small sample project that uses the data from my main app and loaded via JSON at design time. Unfortunately, I can't reproduce the error with GotoKey but it does show how the nested dataset is not sorting based on IndexFieldNames..

https://quality.embarcadero.com/browse/RSP-16884

Thanks,

Dan Palley

Edited by: Dan Palley on Feb 14, 2017 11:54 AM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02