Filtering A TClientDataSet On A NestedDataSet Field

孤街浪徒 提交于 2019-12-07 13:36:51

问题


I have a small application I am working on that is almost finished thanks to those who have assisted me here. I have one last task however. I need to be able to Filter a TClientDataSet on a NestedDataSet field.

ClientDataset1
Field0: Name (Lake Name)
ClientDataset2
Field0: Species (Fish Species)

type
  TDataModule1 = class( TDataModule )
    ClientDataSet1: TClientDataSet;
    ClientDataSet2: TClientDataSet;
    ClientDataSet1Name: TStringField;
    ClientDataSet1County: TStringField;
    ClientDataSet1Town: TStringField;
    ClientDataSet1Area: TStringField;
    ClientDataSet1MaximumDepth: TStringField;
    ClientDataSet1MeanDepth: TStringField;
    ClientDataSet1MapFilename: TStringField;
    ClientDataSet1Species: TDataSetField;
    ClientDataSet2Species: TStringField;
    procedure DataModuleDestroy( Sender: TObject );
  private
    { Private declarations }
  public
    { Public declarations }
  end;

Data:
Nate Pond
    Brook trout
    Creek chub
    Golden shiner
Black Pond
    Brook trout
    Brown bullhead
    Common shiner
Lake Placid
    Lake trout
    Smallmouth bass
    Yellow perch

I need to to filter ClientDataset1 to show all lakes that have Brook trout in the ClientDataset Species field.

Filtered:
Nate Pond
    Brook trout
    Creek chub
    Golden shiner
Black Pond
    Brook trout
    Brown bullhead
    Common shiner

How can a filter (or other means) be created to accomplish this? Are there any third-party componets that will do this?

Thanks,

Bill


回答1:


Try adding an OnFilterRecord handler to the master dataset and use Locate on the nested dataset inside the handler to see if the record exists.



来源:https://stackoverflow.com/questions/465647/filtering-a-tclientdataset-on-a-nesteddataset-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!