Post by Nick Hodges (TeamB)Yeah, sadly, this is going to be tough to do. OnFilterRecord doesn't
have a simple way to hook into it -- it's called in the RecordFilter
method which is private, and thus not virtual.
You might give SetOnFilterRecord a look -- you might be able to hook in
that way.
Thanks for the hint.
There were some pitfalls on the way but now I have it.
May be it's of interest:
type
TAttribute = longInt; // as TIntegerField
TAttrTable = class(TTable)
private
FAttrFiltered: Boolean;
FAttrFilter: TAttribute;
FExtOnFilterRecord : TFilterRecordEvent;
procedure SetAttrFiltered(const Value: Boolean);
procedure FilterRecordAttributes(DataSet: TDataSet; var Accept:
Boolean);
procedure SetAttrFilter(const Value: TAttribute);
protected
procedure DoBeforeOpen; override;
function GetOnFilterRecord : TFilterRecordEvent;
procedure SetOnFilterRecord(const Value: TFilterRecordEvent);
override;
public
constructor Create(AOwner: TComponent); override;
published
property AttrFilter : TAttribute read FAttrFilter write
SetAttrFilter;
property AttrFiltered : Boolean read FAttrFiltered write
SetAttrFiltered;
property OnFilterRecord: TFilterRecordEvent read
GetOnFilterRecord write SetOnFilterRecord;
end;
implementation
{ TAttrTable }
constructor TAttrTable.Create(AOwner: TComponent);
begin
inherited;
FAttrFiltered:= false;
FAttrFilter:= 0;
FExtOnFilterRecord:= NIL;
inherited setOnFilterRecord(FilterRecordAttributes);
end;
procedure TAttrTable.FilterRecordAttributes(DataSet: TDataSet; var
Accept: Boolean);
begin
if Accept then begin
if AttrFiltered then Accept:= ((AttrField.AsInteger and
AttrFilter) = AttrFilter);
if Accept and assigned(FExtOnFilterRecord) then
FExtOnFilterRecord(DataSet, Accept);
end; // else already false
end;
function TAttrTable.GetOnFilterRecord: TFilterRecordEvent;
begin
result:= FExtOnFilterRecord;
end;
procedure TAttrTable.SetAttrFilter(const Value: TAttribute);
begin
if FAttrFilter <> Value then begin
FAttrFilter := Value;
if Filtered and AttrFiltered and active then refresh;
end;
end;
procedure TAttrTable.SetAttrFiltered(const Value: Boolean);
begin
if FAttrFiltered <> Value then begin
FAttrFiltered := Value;
if Filtered and active then refresh;
end;
end;
procedure TAttrTable.setOnFilterRecord(const Value:
TFilterRecordEvent);
begin
FExtOnFilterRecord:= value;
inherited setOnFilterRecord(FilterRecordAttributes);
end;
end.