View Issue Details

IDProjectCategoryView StatusLast Update
0003373JEDI VCL00 JVCL Componentspublic2006-01-24 02:04
Reporterivan_raAssigned ToAHUser 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 
Target VersionFixed in Version3.20 
Summary0003373: TJvDBTreeView: change visibility again
DescriptionIssue http://homepages.borland.com/jedi/issuetracker/view.php?id=3256 corrects change visibility problem for TJvDBTreeView - now it can restore expanded end selected state after hiding.
But this is one more small problem: TJvDBTreeView creates nodes dynamically - so, if TreeNode.HasChildren=true, in practice ChildCount can be 0 - they creates after expanding of node. So, if TJvDBTreeView has not yet expanding nodes (but HasChildren), after hiding and showing TJvDBTreeView looses information afout this nodes - they become empty.
Additional InformationThis is solution for this case: we must save and restore TreeNode.HasChildren information in DestroyWnd and CreateWnd procedures:

procedure TJvCustomDBTreeView.DestroyWnd;
var
  Node: TTreeNode;
  temp:string;
  l:integer;
  HasChildren:byte; ///////////// NEW CODE
begin
  if Items.Count > 0 then
  begin
    // save master values into stream
    FMastersStream:= TMemoryStream.Create;
    Node := Items.GetFirstNode;
    while Node <> nil do
    begin
      // save MasterValue as string
      temp:=VarToStr(TJvDBTreeNode(Node).MasterValue);
      l:=length(temp);
      FMastersStream.Write(l,SizeOf(l));
      FMastersStream.Write(temp[1],l);
      HasChildren:=Byte(Node.HasChildren); /////////////// NEW
      FMastersStream.Write(HasChildren,1); /////////////// CODE
      Node := Node.GetNext;
    end;
  end;
  inherited DestroyWnd;
end;

procedure TJvCustomDBTreeView.CreateWnd;
var
  Node: TTreeNode;
  temp:string;
  l:integer;
  HasChildren:byte; ///////////// NEW CODE
begin
  inherited CreateWnd;
  // tree is restored. Now we must restore information about Master Values
  if assigned(FMastersStream) and (Items.Count > 0)
  then begin
    Node := Items.GetFirstNode;
    FMastersStream.Position:=0;
    while Node <> nil do
    begin
      FMastersStream.Read(l,SizeOf(l));
      SetLength(temp,l);
      FMastersStream.Read(temp[1],l);
      TJvDBTreeNode(Node).SetMasterValue(temp);
      FMastersStream.Read(HasChildren,1); /////////////// NEW
      Node.HasChildren:=boolean(HasChildren); /////////////// CODE
      Node := Node.GetNext;
    end;
    FreeAndNil(FMastersStream);
  end;
end;
TagsNo tags attached.

Activities

ivan_ra

2006-01-23 08:26

developer   ~0008426

You can check this bug by hiding and showing not expanded TJvDBtreeView: if one of nodes has childs but not expanded, after hiding and showing of tree, this node looks as leaf (has not childs). After applying of shown code problem closes

AHUser

2006-01-24 02:04

developer   ~0008436

Fixed in CVS.

Issue History

Date Modified Username Field Change
2005-12-21 08:05 ivan_ra New Issue
2006-01-23 08:26 ivan_ra Note Added: 0008426
2006-01-24 02:04 AHUser Status new => resolved
2006-01-24 02:04 AHUser Resolution open => fixed
2006-01-24 02:04 AHUser Assigned To => AHUser
2006-01-24 02:04 AHUser Note Added: 0008436