Hi,
this component is really great but I found some issue. When my table is empty, everything is ok. When table has some data - parent node, more child nodes etc. it's still ok. But when my table has only one node (parent node) without any child nodes, my program crashes and shows error in this section:
(******************************************************************************
* Synchronize the tree with database after adding a row directly into DB.
*******************************************************************************)
procedure TZedDBTreeView.CheckAppend;
var
Node : TZedTreeNode;
begin
if (DatasetAvailable) and ((FTextDataLink.DataSet.RecordCount - Self.Items.Count) = 1) then
begin
Self.BeginUpdate;
try
Node := Self.Items.AddNewChild(GetNodeByID(FParentDataLink.Field.AsInteger), FTextDataLink.Field.AsString);
Node.ID := FTextDataLink.DataSet.FieldByName(FIDField).AsInteger;
Node.ParentID := FParentDataLink.Field.AsInteger;
finally
Self.EndUpdate;
end;
end;
end;
My table looks like this:
id pid name
main root node has pid field as null.