Grid Filtering when using a Database Adapter

G'day,


Using a TTMSFNCGrid and a TTMSFNCGridDatabaseAdapter, is there any way to implement Filtering?

At the moment I've got as far as using OnNeedFilterDropDownData to populate the filter menu by hand, and then using OnFilterSelect to try and filter the data the dataset directly, but it doesn't feel like this is an approach that will work.

Any help greatly appreciated.

Cheers

Mike

When you use TTMSFNCGridDatabaseAdapter, the filtering indeed needs to be done at dataset level. In the OnFilterSelect, get the selected filter condition and apply it to the dataset. Call Abort; from this event handler to stop further processing from the grid itself for filtering.

Unless I'm not understanding you correctly, calling abort; in the OnFilterSelect results in repeating calls to my event handler.

By calling Abort in the event handler, code is now not called in your procedure TTMSFNCCustomGrid.HandleFilterTimer(Sender: TObject); 

Specifically, the timer is never disabled, and this is what is causing the repeated calls to my event handler.

My event handler at the moment is pretty simple. 



procedure TForm1.TMSFNCGrid1FilterSelect(Sender: TObject; Col: integer;
  var Condition: string);
begin
  // Use Col and Condition to prepare and apply a filter for FDataset
  Abort;
end; 



Hi, 


We have investigated this here and you can use the OnAfterApplyFilter event to filter on dataset level. Below is a sample that demonstrates this.

procedure TForm1.TMSFNCGrid1AfterApplyFilter(Sender: TObject; Col: Integer;
  Condition: string; var UpdateCalculations: Boolean);
begin
  ClientDataSet1.Filtered := False;
  if Condition = sTMSFNCGridFilterAll then
    Exit;

  ClientDataSet1.FilterOptions := [foCaseInsensitive];
  ClientDataSet1.Filter := 'Brand LIKE ''%' + Condition + '%''';
  ClientDataSet1.Filtered := True;
end;