Alexander Stolte Expert Licensed User Longtime User May 16, 2019 #1 Hey, this question is a general programming question. My goal is a Treeview Structure. I have the following Database Structure: id and parent_id If parent_id = 0 Then it is a root item. My considerations were a For Each loop This is just pseudo code: B4X: For Each id in table If parent_id = 0 then add item to list For Each parent_id In id if id = parent_id then add item to second level end if NExt End if Next How would you solve such an assignment?
Hey, this question is a general programming question. My goal is a Treeview Structure. I have the following Database Structure: id and parent_id If parent_id = 0 Then it is a root item. My considerations were a For Each loop This is just pseudo code: B4X: For Each id in table If parent_id = 0 then add item to list For Each parent_id In id if id = parent_id then add item to second level end if NExt End if Next How would you solve such an assignment?
Erel B4X founder Staff member Licensed User Longtime User May 16, 2019 #2 Are you asking about the UI implementation or about the data structure? The data structure should be based on a custom type such as this one: B4X: Type TreeElement (Children As List, Value As Object, Parent As TreeElement) Each element in the Children list is a TreeElement type. Upvote 0
Are you asking about the UI implementation or about the data structure? The data structure should be based on a custom type such as this one: B4X: Type TreeElement (Children As List, Value As Object, Parent As TreeElement) Each element in the Children list is a TreeElement type.