TMSFMXGrid1.Filter doesn't work with spaces

It seems that if you have a space in your data and you are trying to add multiple filters, the filtering does not work.


Ive tried:


procedure TForm1.TMSFMXGrid1FilterSelect(Sender: TObject; Col: Integer; var Condition: string);
var
  fd: TFilterData;
begin
  TMSFMXGrid1.RemoveFilters;
  fd := TMSFMXGrid1.Filter.Add;
  fd.Column := 1;
  fd.Condition := '=''Test 5''';


  fd := TMSFMXGrid1.Filter.Add;
  fd.Column := 1;
  fd.Condition := '=''Test 9''';
  fd.Operation := foOR;
  TMSFMXGrid1.ApplyFilter;
end;

And it doesnt work. Ive also tried: 
  fd.Condition := '=Test 5';
as well as
  fd.Condition := '''Test 5''';

It doesnt seem to work.

What is the correct way to get it to work?

Thanks!

I have retested this here with a default TTMSFMXGrid on the form and the code:


procedure TForm5.Button1Click(Sender: TObject);
var
  fd: TFilterData;
begin
  TMSFMXGrid1.Filter.Clear;

  fd := TMSFMXGrid1.Filter.Add;
  fd.Column := 1;
  fd.Condition := '"Test 5"';

  fd := TMSFMXGrid1.Filter.Add;
  fd.Column := 1;
  fd.Condition := '"Test 9"';
  fd.Operation := foOR;

  TMSFMXGrid1.ApplyFilter;

end;

procedure TForm5.FormCreate(Sender: TObject);
begin
  TMSFMXGrid1.LoadFromCSV('e:\tms\cars.csv');
  TMSFMXGrid1.Cells[1,5] :='Test 5';
  TMSFMXGrid1.Cells[1,10] :='Test 9';
end;

and I cannot see an issue. Two rows are withheld after filtering, the one with "Test 5" and the one with "Test 9".

Do you use the latest version of the components?

It works fine if you do it from a button, however, if you do it from the FilterSelect Event it does not.


Thanks!

It's not clear how you intend to use this from the OnFilterSelect event. The filter dropdown already has a value selected from the dropdown and this value can be manipulated via the var Condition parameter. It is with this condition parameter that the grid will construct the filter itself internally.

We tried setting the conditions and it did not work when there were two or more conditions - such as using the | (OR) condition. We are launching an Excel style custom window to collect more than one condition. We thought since it wasnt working using the condition parameter we would try the filter.add way. Either way it doesnt seem to work.

With setting the condition with an OR operation, I cannot see an issue here.

Test code:

procedure TForm4.TMSFMXGrid1FilterSelect(Sender: TObject; Col: Integer;
  var Condition: string);
begin
  Condition := '"Test 5"^"Test 9"';
end;