Export file from the two linked tables

 

Here is the example of DB Schema

 

 

def get_name(c):

            row = db(db.child.id == c).select(db.child.name).first()

            return row.name

 

 

*Child Table*

* *

db.define_table('child',

    Field('name')

    )

            

 

*Parent Table*

* *

db.define_table('parent',

    Field('Cname'),

            Field('fname', db.child, represent=lambda c, row:get_name(c), 
requires = IS_IN_DB(db,'child.id','%(name)s')),

            Field('mname', db.child, represent=lambda c, row:get_name(c), 
requires = IS_IN_DB(db,'child.id','%(name)s'))

            

            )

             

 

 

The data should be exported as CSV file, but ....

The exported CSV file should contain the data *as shown on the screen *i.e 
it should contain the *names* of mother and father,*not* the IDs from 
Parent table.

 

def imf():

                db.Trademark.id.readable=False

                table = SQLFORM.grid(db.parent, maxtextlength=100, 
selectable = lambda ids: del_imf(ids) , formstyle = 'table3cols', 
paginate=5 , sorter_icons=(XML('↑'), XML('↓')) , 
deletable=False , showbuttontext=False , search_widget='default' ) 

                

                

                return dict(table=table) 

 

 

def del_imf(ids):

                if not ids:

                                response.flash='Please Select the Check-box 
to Delete'

                else:

                                for row in ids:

                                                db(db.Trademark.id == 
row).delete()

                                pass

                pass

                return ''

 

can it possible 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to