Class SQLTABLE
source code
object --+
|
html.XmlComponent --+
|
html.DIV --+
|
html.TABLE --+
|
SQLTABLE
given a Rows object, as returned by a db().select(), generates
an html table with the rows.
optional arguments:
:param linkto: URL (or lambda to generate a URL) to edit individual records
:param upload: URL to download uploaded files
:param orderby: Add an orderby link to column headers.
:param headers: dictionary of headers to headers redefinions
headers can also be a string to gerenare the headers from data
for now only headers="fieldname:capitalize",
headers="labels" and headers=None are supported
:param truncate: length at which to truncate text in table cells.
Defaults to 16 characters.
:param columns: a list or dict contaning the names of the columns to be shown
Defaults to all
Optional names attributes for passed to the <table> tag
The keys of headers and columns must be of the form "tablename.fieldname"
Simple linkto example::
rows = db.select(db.sometable.ALL)
table = SQLTABLE(rows, linkto='someurl')
This will link rows[id] to .../sometable/value_of_id
More advanced linkto example::
def mylink(field, type, ref):
return URL(r=request, args=[field])
rows = db.select(db.sometable.ALL)
table = SQLTABLE(rows, linkto=mylink)
This will link rows[id] to
current_app/current_controlle/current_function/value_of_id
New Implements: 24 June 2011:
-----------------------------
:param selectid: The id you want to select
:param renderstyle: Boolean render the style with the table
:param extracolums = [{'label':A('Extra',_href='#'),
'class': '', #class name of the header
'width':'', #width in pixels or %
'content':lambda row, rc: A('Edit',_href='edit/%s'%row.id),
'selected': False #agregate class selected to this column
}]
:param headers = {'table.id':{'label':'Id',
'class':'', #class name of the header
'width':'', #width in pixels or %
'truncate': 16, #truncate the content to...
'selected': False #agregate class selected to this column
},
'table.myfield':{'label':'My field',
'class':'', #class name of the header
'width':'', #width in pixels or %
'truncate': 16, #truncate the content to...
'selected': False #agregate class selected to this column
},
}
table = SQLTABLE(rows, headers=headers, extracolums=extracolums)
|
__init__(self,
sqlrows,
linkto=1,
upload=1,
orderby=1,
headers={ } ,
truncate=16,
columns=1,
th_link='
' ,
extracolumns=1,
selectid=1,
renderstyle=True,
**attributes)
:param *components: any components that should be nested in this
element :param **attributes: any attributes you want to give to this
element |
source code
|
|
|
|
Inherited from html.DIV :
__delitem__ ,
__getitem__ ,
__len__ ,
__nonzero__ ,
__setitem__ ,
__str__ ,
append ,
element ,
elements ,
flatten ,
insert ,
sibling ,
siblings ,
update ,
xml
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__
|
Inherited from object :
__class__
|
__init__(self,
sqlrows,
linkto=1,
upload=1,
orderby=1,
headers={ } ,
truncate=16,
columns=1,
th_link='
' ,
extracolumns=1,
selectid=1,
renderstyle=True,
**attributes)
(Constructor)
| source code
|
:param *components: any components that should be nested in this
element :param **attributes: any attributes you want to give to this
element
:raises SyntaxError: when a stand alone tag receives components
- Overrides:
html.DIV.__init__
- (inherited documentation)
|