Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hierarchical Grouping Levels

Status
Not open for further replies.

jsaint

IS-IT--Management
Nov 7, 2001
7
US
I am trying to determine # of levels deep into a hieracrhical grouping I am so I can conditionally format based on level.
I want to be able to have the users input # of levels deep to display and then only have the hieracrhical group go that number.
I also want to indent the group name, but not the details - and have the details all line up regardless of # of levels deep. If I could determine the # of level deep, I can set up a formula to add preceeding spaces to the group name field based on # levels deep and handle the indent that way leaving the details not indented.
Does anyone know ho to determine level?
thanks!
Jack
 
One way would be to maintain a variable that gets incremented in the group header section and decremented in the group footer section. Steve Phillips, Crystal Consultant
 
Thanks, Steve.
I ended up creating a formula in the group header to display the level. It creates an array of parent ids. Since Crystal sorts hierarchically by id, the parent is always before the child. Every time a child is read, I spin back through the array looking for the parent and calculate the child level to be 1 below the parent. Then I stored the child in the array as a possible future parent. The code looks like this (since we will never have more than 20-25 levels, I set the array at 100):

global numbervar levelsdeep;
numbervar array holdparents;
numbervar i;

If isnull ({DEPT.PARENT_DEPT_ID})
then
(
levelsdeep :=1;
redim holdparents[100];
holdparents[1]:={DEPT.ID};
);

For i := 1 to 100 do
(
If {DEPT.PARENT_DEPT_ID} = holdparents
then
(
levelsdeep := i + 1;
holdparents[i+1] := {DEPT.ID};
)
);

levelsdeep;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top