Trees

13 views
Skip to first unread message

Andre Luan

unread,
May 9, 2011, 3:04:29 AM5/9/11
to geraldo-users
Is there any support for trees? Suppose I have an object from class A,
and it has a attribute that is a list of object of class B. Every
object in this last class have another attribute that is a list of
class C objects. If I want to display this hierarchy in a report like
a tree, how do I proceed?

Thanks.

musa fedakar

unread,
May 16, 2011, 7:06:41 AM5/16/11
to gerald...@googlegroups.com
heys
never tried this but it has to work. or it may give you some ideas.
create a routine in your report class that will add sub bands with your indent argument.

suppose u have

class MasterReport(Report)

---define a function in it like this

   def add_band_detail(self,YOUR_INDENT)
       subz = []
            sub_treeband = SubReport(
                #qset if needed_
                queryset_def = your_model.objects.filter(),
               
                band_detail = ReportBand(
                        auto_expand_height = True,
                        elements=[
                           ObjectValue(attribute_name='description', top=0, left=YOUR_INDENT_ARG+0.2*cm,width=BAND_WIDTH,get_value=lambda instance: '•   ' + u"%s" % instance.description,style={'fontSize': 9,'alignment': TA_LEFT}),
                        ],
                       
                    ),
             
            )
    
     subz.append(sub_treeband)
     return subz


then in views.py
report = MasterReport(queryset=model_)

--> put here ur recursive code that will query your nested data and call 
   report.subreports=report.add_band_detail(YOUR_INDENT_ARG)


well this obviously will not work on first try but i'd try some way like this and i hope u understand the idea. i dont have django installed on this pc at the moment. so i cant  check if my objects statements are correct.

musa.





--
Você está recebendo esta mensagem porque se inscreveu no grupo "geraldo-users" dos Grupos do Google.
Para postar neste grupo, envie um e-mail para gerald...@googlegroups.com.
Para cancelar a inscrição nesse grupo, envie um e-mail para geraldo-user...@googlegroups.com.
Para obter mais opções, visite esse grupo em http://groups.google.com/group/geraldo-users?hl=pt-BR.


Andre Luan

unread,
May 24, 2011, 1:09:03 AM5/24/11
to geraldo-users
I tried with this method, but the problem is that all the data
appears, but not as a hierarchy, for example:

Class A:
propA
propB (this is a list of B type)

Class B:
propC
propD (this is a list of C type)

Class C:
propE

When I use two subreports, what happens is:

-classAObj1
-- ClassBObj1
-- ClassBObj2
-- ClassBObj3
----ClassCObj1
----ClassCObj2
-ClassAObj2
--ClassBObj4
etc...

The first child elements appear correctly. The problem is that the
seconds childs appear after the first ones, and not above their
parents. As far as I know, Geraldo is still not able to show list
properties directly, and there is also another problem with the
subreport: for the detail band of a subreport, the queryset is the one
that was defined for it, but in the header band of subreport, the
queryset is the master report's. I don't think it makes sense and also
getting hopeless on solving this problem.
Reply all
Reply to author
Forward
0 new messages