Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Share Me

  • Please share this topic with your friends. Click any of the icons below:
  • Twitter
  • facebook
  • reddit
  • email

TElXTree: Need property: Filtered : Boolean and and OnFilter(...) event

I use the Hidden property to indicate if an item is currently available for activity or not (i.e. Archived). These items may be displayed or not.

Now I need to be able to filter the items based on complex filter criteria that is independent of its Hidden status.

If I had the following property and event (see below), then I could use the event to filter the items according to my filter.

I would still like Hidden to be independent of the filter, so that Hidden items may be displayed using FilteredVisibility = False, unless the filter rejects them.

The filter would be based on external criteria that is applied to an Item[]'s Text, Cells or Tag values or any other property of the Item[].

property TElXTree.Filtered : Boolean;

event: TElXTree.OnFilter(Sender ; TObject; Item : TElXTreeItem; FilterItem : Boolean);

e.g.

if (   pos('cat', Item.Text) > 0 
  (or (TObjectList<TMyObject>(Data).DateDone < Today() - 6)
  and (CalcTotalTime(Item) < 1)
  and  (Item.Tag > 0) then
begin
  FilterItem := True;
end
else
begin
  FilterItem := False;
end;

A Hidden item is to be filtered like any non-Hidden item.

Of course, if an item is Hidden and FilteredVisibility = True, then there would not be any need to call the event TElXTree.OnFilter(...).

Thank you.
Raymond

Comments

  • 3 Comments sorted by Votes Date Added
  • Did you try OnApplyVisFilterEvent? It allows to built custom filters.
    Note: OnApplyVisFilterEvent triggers if FilteredVisibility = true.
  • Thank you for the suggestion.

    "The event is fired when the user clicks on Filter mark in header section."

    However, I want it to apply to all items when FilteredVisibility is on, without user interaction.

    This should apply to current items and added items, and to items whose Hidden property is changed.

    I'll try it to see how it works. The Help might not be explaining enough.

    Raymond


Sign In or Register to comment.