3

is that possible to hide specific nodes in VirtualStringTree? I'm implementing "filtering" feature (the VST acts as a list with columns), and I'd like to avoid reloading content each time the filter is changed - instead, much faster would be to tell VST not to render specific items ... any solutions?

migajek
  • 8,524
  • 15
  • 77
  • 116
  • 9
    Note that current official VirtualStringTree version incorrectly calculates total heights if nodes have been made invisible. Latest version from SVN fixed that. Link: http://code.google.com/p/virtual-treeview – Linas Jun 09 '10 at 21:13

2 Answers2

16
VirtualTree.IsVisible[Node] := False;
Senseful
  • 86,719
  • 67
  • 308
  • 465
  • thanks! I was looking for something which starts with "visible";) – migajek Jun 09 '10 at 19:46
  • 1
    +1 for using `.IsVisible[]`, which adjusts the overall height of the tree view's canvas so the vertical scroll bar will reflect the hidden node(s). If you simply remove the visible state from the node using `Exclude(Node.States, vsVisible)` or `Node.States := Node.States - vsVisible`, it will not adjust the tree view's canvas height, the vertical scroll bar will not change, and the user will potentially have a lot of white-space beneath the last displayed node. – James L. Oct 29 '13 at 22:27
1

There are problem using .IsVisible[] or .IsFiltered[] and it is that is very slow, i've probe filter in a tree with amoung of 25,000 nodes and is too slow.

I've found one aproach that is faster and solves the problem with scrollbar size when using Include(Node.states,vsFiltered) or (Node.States,vsVisible) is used, it consists on change manually the Node.TotalHeight value acording with the number of visible nodes (not Filtered).

For example i'm filtering 25,000 nodes and the code i was using is the follow :

procedure TFC_Articulo.Filtrar(Filtro:String);
var
 Node:PVirtualNode;
 Data:PArticulo;
begin
  Node := TV.GetFirst;
  TV.RootNode.TotalHeight:=TV.DefaultNodeHeight;  // The Trick
  while Assigned(Node) do
  begin
    Data:=TV.GetNodeData(Node);
    Exclude(Node.States,vsFiltered);     // By default all nodes wil be Visible
    if ComparationHereForDetermineFiltering then
       Include(Node.States,vsFiltered)   // This node wil be filtered
    else
       Inc(TV.RootNode.TotalHeight,Node.NodeHeight);  // Determine the Height of scrollbar
    Node:=TV.GetNext(Node);
  end;
  TV.RootNode.TotalHeight:=TV.RootNode.TotalHeight+TV.BottomSpace;
  TV.UpdateScrollBars(True);
end;

Hope this helps Sorry bad english...