Hi Denes, This seems to do the trick - thanks!,
Carlos On Dec 12, 3:37 pm, DenesL <[email protected]> wrote: > Try this: > > def join(): > rows = db(db.one.id==db.many.one).select(db.many.id, db.many.one, > db.many.xx, db.many.yy, db.many.zz, db.one.aa, db.one.bb, db.one.cc) > tr=[] > f_many='id one xx yy zz'.split() > f_one='aa bb cc'.split() > if len(rows)>0: > r=rows[0] > tr.append([r.many[x] for x in f_many]) > tr[0].extend([r.one[x] for x in f_one]) > for k in range(1,len(rows)): > r=rows[k] > tr.append([r.many[x] for x in f_many]) > print tr > if tr[k][1]==tr[k-1][1]: # many.one > tr[k].extend(['','','']) > else: > tr[k].extend([r.one[x] for x in f_one]) > tbl=TABLE(tr) > return dict(rows=rows, tbl=tbl) > > On Dec 12, 3:47 pm, Carlos <[email protected]> wrote: > > > > > > > > > Hi rochacbruno, > > > That's what I thought, I just wanted to confirm it. > > > Thanks to all !, > > > Carlos > > > On Dec 12, 10:50 am, rochacbruno <[email protected]> wrote: > > > > Carlos, the only solution I see is using a virtual field, or removing > > > repeats in Java Scripts. > > > > Enviado via iPhone > > > > Em 12/12/2010, às 14:17, Carlos <[email protected]> escreveu: > > > > > Hi Denes, > > > > > That's clear to me, my question is not about getting the data (I got > > > > it ok), but instead showing the data in an html table (SQLTABLE) with > > > > unique (no repeated) "one" data, as per my examples above. > > > > > Maybe I'm not explaining clearly? - sorry :-) > > > > > Thanks!, > > > > > Carlos > > > > > On Dec 12, 9:41 am, DenesL <[email protected]> wrote: > > > >> Hi Carlos, > > > > >> inside the select you can specify which fields to bring back, I think > > > >> you want: > > > > >> rows = db(db.one.id==db.many.one).select(db.many.id, db.many.xx, > > > >> db.many.yy, db.many.zz, db.one.aa, db.one.bb, db.one.cc) > > > > >> On Dec 12, 9:58 am, Carlos <[email protected]> wrote: > > > > >>> Hi Massimo, > > > > >>> What do you mean?, that shows the same result (with repeated 'one' > > > >>> data) in the SQLTABLE, doesn't it?. > > > > >>> Thanks, > > > > >>> Carlos > > > > >>> On Dec 12, 1:23 am, mdipierro <[email protected]> wrote: > > > > >>>> You can do, for example: > > > > >>>> rows = > > > >>>> db(db.one.id==db.many.one).select(db.many.id,db.many.one,db.many.xx,db.many > > > >>>> .yy,db.many.zz,db.one.aa,db.one.bb,db.one.cc) > > > > >>>> On Dec 11, 12:27 pm, Carlos <[email protected]> wrote: > > > > >>>>> Hi, > > > > >>>>> I need to show a SQLTABLE with joined data but without repeated > > > >>>>> information (like grouping but showing all rows). > > > > >>>>> Let's say I have the following model: > > > > >>>>> db.define_table('one', Field('aa'), Field('bb'), > > > >>>>> Field('cc'), > > > >>>>> format='%(aa)s') > > > >>>>> db.define_table('many', Field('one', 'reference one'), > > > >>>>> Field('xx'), > > > >>>>> Field('yy'), Field('zz')) > > > > >>>>> And the following function: > > > > >>>>> def join(): > > > >>>>> rows = db(db.one.id==db.many.one).select() > > > >>>>> return dict(rows=rows) > > > > >>>>> This shows all rows correctly but with repeated data for 'one': > > > > >>>>> many.id many.one many.xx many.yy many.zz one.id one.aa > > > >>>>> one.bb one.cc > > > >>>>> 1 a1 a1_x1 a1_y1 a1_z1 2 a1 b1 c1 > > > >>>>> 2 a1 a1_x2 a1_y2 a1_z2 2 a1 b1 c1 > > > >>>>> 3 a2 a2_x1 a2_y1 a2_z1 3 a2 b2 c2 > > > >>>>> 4 a2 a2_x2 a2_y2 a2_z2 3 a2 b2 c2 > > > >>>>> 5 a3 a3_x1 a3_y1 a3_z1 4 a3 b3 c3 > > > > >>>>> How can I show this same view (with the same number of rows) but > > > >>>>> only > > > >>>>> showing the 'one' data once (for the first occurrence) as follows?. > > > > >>>>> many.id many.one many.xx many.yy many.zz one.id one.aa > > > >>>>> one.bb one.cc > > > >>>>> 1 a1 a1_x1 a1_y1 a1_z1 2 a1 b1 c1 > > > >>>>> 2 a1 a1_x2 a1_y2 a1_z2 2 > > > >>>>> 3 a2 a2_x1 a2_y1 a2_z1 3 a2 b2 c2 > > > >>>>> 4 a2 a2_x2 a2_y2 a2_z2 3 > > > >>>>> 5 a3 a3_x1 a3_y1 a3_z1 4 a3 b3 c3 > > > > >>>>> Note the empty spaces in order to show the 'one' data once only (on > > > >>>>> first occurrence). > > > > >>>>> Thanks, > > > > >>>>> Carlos

