Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: Accessing rows in filtered dataset by index?


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


Permlink Replies: 3 - Last Post: Nov 13, 2017 12:54 AM Last Post By: Mark Williams
Mark Williams

Posts: 120
Registered: 5/8/10
Accessing rows in filtered dataset by index?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 12, 2017 6:49 AM
I am using a VirtualStringTree to display results from a firedac query.

To populate the node data I am referencing the dataset row by its index eg
Celltext:=DAC.FDQuery1.Table.rows[Node.index].GetData(0);


This approach works fine until I apply a filter to the query. The rows property refers to the unfiltered dataset

Is there some way of accessing the rows in the query by reference to some index or is there some other efficient way to do this? I would rather not switch to a dbGrid if I can avoid it.
Mark Williams

Posts: 120
Registered: 5/8/10
Re: Accessing rows in filtered dataset by index?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 12, 2017 10:50 AM   in response to: Mark Williams in response to: Mark Williams
I have found the FilteredData property which does what I need. So taking the original example code, instead of accessing the queries table property, you reference its filteredData like so:
FDQuery1.FilteredData.DataView.rows[Node.Index].GetData(0);
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Accessing rows in filtered dataset by index?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 12, 2017 12:02 PM   in response to: Mark Williams in response to: Mark Williams
FDQuery1.FilteredData.DataView.rows[Node.Index].GetData(0);

More simple:
FDQuery1.SourceView.rows[Node.Index].GetData(0);


--
With best regards,
Dmitry
Mark Williams

Posts: 120
Registered: 5/8/10
Re: Accessing rows in filtered dataset by index?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 13, 2017 12:54 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
More simple:
FDQuery1.SourceView.rows[Node.Index].GetData(0);


Thanks. What is the difference between SourceView and FilteredData.DataView?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02