DBTreeView multilevel parent-child, with one datasource

98 views
Skip to first unread message

Kovács Péter

unread,
Mar 6, 2017, 10:37:39 AM3/6/17
to Rosi Delphi Components
Hello,

I have a table structure like:

|id|name|parent_id

the connection between the items is also simple:
if parent_id is not null, than the item has a parent, and the value means the id of the parent

the result I need is a treeview, with parent-child nodes like:

+parent1
----child1
+parent2
----child2
----child3
---+child4withchild
------child4child1

But cna't figure out the needed DataItem definitions, and properties.

Is this possible, with a tabla or a single query datasource?

Tomas Rosinsky

unread,
Mar 6, 2017, 11:46:04 AM3/6/17
to Rosi Delphi Components
Hello,
yes, my rDBTreeView supports multilevel mode and setting is quite simple.
Just open DataItemDefs, add new item and set following properties:

Datasource - link to your datasource/dataset with all records
ListAllRecords = true
MultilevelMode = true
KeyFieldName = Id
ParentKeyFieldName = parent_id
RecordTexMask = <<name>>

Then open dataset (sorted in needed order) and call rDBTreeView.RefreshData to load all structure.

I hope it helps.
Tomas

Kovács Péter

unread,
Mar 7, 2017, 2:28:20 AM3/7/17
to Rosi Delphi Components
Unfortunatelly no success.

I tried the way, you worte, but after open tha adoquery, behind the dataset, the treeview, remains empty (before open it shows, a text that dataset is closed)

I make a blank project with RAD Studio 10.1, create a VCL app, with only a few item: TADOCOnnection,TADOQuery,TDataSource, a buton, and a TrDBTreeView.
Fill the connection string, and the query sql with a simple select * from... 
Than setup the dataitem as you suggest.
The button click event do only two things, open the query, then call RefreshData



The exact field names you can see in the ssms screenshot.

Tomas Rosinsky

unread,
Mar 7, 2017, 2:47:55 AM3/7/17
to Rosi Delphi Components
Hello, could you send me your demo project to check the issue? Send it please to my contact email.
Thanks
Tomas

Kovács Péter

unread,
Mar 7, 2017, 3:24:09 AM3/7/17
to Rosi Delphi Components
I sent it, thanks for your time!

Tomas Rosinsky

unread,
Mar 7, 2017, 4:20:42 AM3/7/17
to Rosi Delphi Components
The issue is the null values in parent ID for top level item because current version filter zero values only. It was solved easilly by modification of select command:

select cikkcsop,cikkcsnev1,isnull(szulo_ccsop,0) as szulo_ccsop from cikkcsop order by szulo_ccsop,cikkcsnev1


Above that rDBTreeView was updated to support any value for top level items by new property MultilevelTopLevelFilter
Tomas

miwa...@gmail.com

unread,
Mar 10, 2017, 5:38:11 AM3/10/17
to Rosi Delphi Components
"Above that rDBTreeView was updated to support any value for top level items by new property MultilevelTopLevelFilter"

It is already in v11.50, or just be?

Michal

Tomas Rosinsky

unread,
Mar 10, 2017, 7:15:09 AM3/10/17
to Rosi Delphi Components
Yes, I've just updated current version 11.5 (version with source code only). Just download the package again by your download link. There is new property "MultilevelTopLevelFilter".
Tomas
Reply all
Reply to author
Forward
0 new messages