Sharpie
Sharpie

Reputation: 383

Filter ClientDataSet

I have a delphi form which has a cxGrid on it. This grid is populating records via a clientdataset.

Typing into a tedit box and clicking a button, I would like to be able to filter the grid to display records from what is entered into the tedit box.

So far I have this but it doesn't pull back any records.

dmodule.cds.DisableControls;
try
  dmodule.cds.Filtered := False;
  dmodule.cds.FilterOptions := [];

  dmodule.cds.Filter := 'Field LIKE''%' + editSearch.Text+ '%''';

  dmodule.cds.Filtered := True;
finally
  dmodule.cds.EnableControls;
end;

Any help would be much appreciated.

Thanks,

Upvotes: 0

Views: 1171

Answers (1)

R.P Silveira
R.P Silveira

Reputation: 402

Just try these simple changes below:

dmodule.cds.FilterOptions := [foCaseInsensitive,foNoPartialCompare];
dmodule.cds.Filter := 'Field LIKE '+ QuotedStr('%'+ editSearch.Text + '%');

I've tested here with a cxGrid and it worked fine.

Upvotes: 3

Related Questions