Forum OpenACS Development: nested group problem

Collapse
Posted by Gerald Stermsek on
I have these nested multirow statements:

@x.a@
group column="A"
@x.b@
group column="B"
@x.c@

With the dataset below group in adp does not recognize
the change in column A because it repeats until column B
changes.

A B C
1 2 3
2 2 3

should become

1
  2
    3
2
  2
    3

but multirow does

1
  2
    3
    3

because column B does not change.

what can I do to fix that?

regards,
Gerald

Collapse
2: Re: nested group problem (response to 1)
Posted by Don Baccus on
It is working the way it is supposed to work ...

You may have to do what you want manually, i.e. by setting flags in the execution block of your db_multirow or something like that.

Collapse
3: Re: nested group problem (response to 2)
Posted by Tilmann Singer on
I don't understand your problem - the dataset you posted seems to only contain 2 rows, and you want it to return 6 rows?
Collapse
4: Re: nested group problem (response to 1)
Posted by Peter Alberer on
Unfortunately nesting group tags is currently not working. The fastest way to get what you want is probably to create the whole html-part in tcl. Of course you could take a look at the template-procs and try to get nested group tags working, but i think that could be rather difficult.
Collapse
5: Re: nested group problem (response to 4)
Posted by Gerald Stermsek on
Thanks for your comment, I already did it in tcl

Regards,
Gerald

Collapse
6: Re: nested group problem (response to 5)
Posted by Tilmann Singer on
Nested group tags work fine for me.

You propably meant that nested multirows don't work, which is true. They don't need to work either, that's what the group tag is for!

Collapse
7: Re: nested group problem (response to 6)
Posted by Gerald Stermsek on
tcl:
multirow create test a b c
multirow append test feedback shirt blue
multirow append test rating shirt blue

adp:
@test.a@<br>
<group column="a">
@test.b@<br>
<group column="b">
@test.c@<br>
</group>
</group>
</group>

delivers:

feedback
shirt
blue
blue

I want:

feedback
shirt
blue
rating
shirt
blue

when in <group column="b"> the template processer
does not recognize the change in column a and
prints two times column c

that's my problem.
I did it in tcl and passed it in onevalue, by the way

regards,
Gerald

Collapse
8: Re: nested group problem (response to 1)
Posted by Tilmann Singer on
Ah, now I see what you mean - yes, this is obviously a bug.

Seems like when I used nested group tags I never had the situation where column 2 stayed the same and column 1 changed.

Collapse
9: Not a Bug (response to 1)
Posted by Benjamin Bytheway on
I think there's a misunderstanding of what the group tag actually does.  What you're seeing is correct behavior, even though it many not be exactly what you would expect at first glance.

The group tag doesn't operate on a seperate rowset for each instance of the group tag.  Only one rowset is operated on for the entire multirow.  Since you only have 2 rows coming out of the database, you can only have one group tag looping, and it will repeat only once. Once that group tag has looped, here are no more rows for the other group tags to compare against, so the multirow ends since it has output the last row.

I'm wondering why a simple multiple tag wouldn't work in this case.  If you want to print out in order the columns of the data in order, why not do:

<multiple name="test">
  @test.a@
  @test.b@
  @test.c@
</multiple>

In the example you mentioned, this would result in:

feedback
shirt
blue
rating
shirt
blue

Collapse
10: Re: nested group problem (response to 1)
Posted by Tilmann Singer on
Benjamin - it is a bug. See the following test case:

tcl:

multirow create test f1 f2 f3
multirow append test I 1 a
multirow append test I 1 b
multirow append test I 1 c
multirow append test I 2 a
multirow append test I 2 b
multirow append test II 1 a
multirow append test II 1 b
multirow append test II 2 a
multirow append test II 2 b

---
adp:

<multiple name="test">
<h1>f1: @test.f1@ </h1>
<group column="f1">
<h2>f2: @test.f2@</h2>
<group column="f2">
f3: @test.f3@
<br>
</group>
</group>
</multiple>

---
output:

f1: I

f2: 1

f3: a
f3: b
f3: c

f2: 2

f3: a
f3: b

f1: II

f2: 1

f3: a
f3: b

f2: 2

f3: a
f3: b

--------

Now when one line of the data is changed in this way:

multirow create test f1 f2 f3
multirow append test I 1 a
multirow append test I 1 b
multirow append test I 1 c
multirow append test I 2 a
multirow append test I 1 a
multirow append test II 1 a
multirow append test II 1 b
multirow append test II 2 a
multirow append test II 2 b

---
the output becomes:

f1: I

f2: 1

f3: a
f3: b
f3: c

f2: 2

f3: a

f2: 1

f3: a
f3: a
f3: b

f2: 2

f3: a
f3: b

------

Which means it does not detect the change in column f1 and never repeats the outermost loop, which it should. I am adding this on bugtracker now.