如何创建分层树 [英] How to create a hierarchical tree
问题描述
我正在使用 iReport 4.2 而我正在尝试从数据库中执行以下操作
I am using iReport 4.2 and I am trying to do the following
我以BOM格式(或树)获取数据格式)现在我需要根据级别移动字段。我正在做一个分层树
from database I get data in BOM like format (or tree format) and now I need to shift fields right according to the level. I am doing a hierarchical tree
例如
A.
A.a
A.b
B.
B.a
B.a.a
任何建议。我做了一些研究,我甚至不知道该寻找什么:)
Any suggestions. I did some research and I don't even know what to look for :)
推荐答案
我写了以下选择我改变的地方带有空格的ID乘以等级
I wrote the following select where I changed the ids with blanks multiplied with the level
从ocs_season_report_unit
中选择ocs_season_questionnaire_id,id,代码,标题,描述,0,'1'
其中supervisor_id为null且ocs_season_questionnaire_id = 5
select ocs_season_questionnaire_id ,id, code, title, description, 0, '1' from ocs_season_report_unit where supervisor_id is null and ocs_season_questionnaire_id = 5
union all
select C.ocs_season_questionnaire_id, C.id, C.code, C.title, C.description, depth+1, xid||'.'||C.id
from sumthis P
inner join ocs_season_report_unit C on P.id = C.supervisor_id
)
select id, lpad('', depth*2)||title as title, description from sumthis where ocs_season_questionnaire_id = $P{qu_id}
这不是最佳解决方案,所以如果有人知道更好的解决方案,请回复。
谢谢
It is not the best solution so if anybody knows a better one please respond. thank you
这篇关于如何创建分层树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!