Package turbogears :: Package widgets :: Module datagrid :: Class DataGrid

Class DataGrid

source code

 object --+    
base.Widget --+
Known Subclasses:

Generic widget to present and manipulate data in a grid (tabular) form.

The columns to build the grid from are specified with fields ctor argument which is a list. Currently an element can be either a two-element tuple or instance of DataGrid.Column class. If tuple is used it a Column is then build out of it, first element is assumed to be a title and second element - field accessor.

You can specify columns' data statically, via fields ctor parameter, or dynamically, by via 'fields' key.

Nested Classes
Simple struct that describes single DataGrid column.
Helper class that returns an object's attribute when called.

Inherited from base.Widget: __metaclass__

Instance Methods
__init__(self, *args, **kw)
Widget initialization.
source code
get_column(self, name)
Return DataGrid.Column with specified name.
source code
__getitem__(self, name)
Shortcut to get_column.
source code
update_params(self, d)
Update the template parameters.
source code

Inherited from base.Widget: __call__, __repr__, __setattr__, adjust_value, display, render, retrieve_css, retrieve_javascript

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __sizeof__, __str__, __subclasshook__

Static Methods
Return a function to access the fields of table by row, col.
source code
Class Variables
  css = [CSSLink(name='grid.css', media='all', order=0)]
  template = "turbogears.widgets.templates.datagrid"
  fields = None
  template_c = 'turbogears.widgets.templates.datagrid'

Inherited from base.Widget: default, javascript, name, params, params_doc


Inherited from base.Widget: is_named

Inherited from object: __class__

Method Details

__init__(self, *args, **kw)

source code 
Widget initialization.

All initialization has to take place in this method.
It's not thread-safe to mutate widget's attributes outside this method
or anytime after widget's first display.

*Must* call super(MyWidget, self).__init__(*args, **kw) cooperatively,
unless, of course, your know what you're doing. Preferably this should
be done before any actual work is done in the method.


name     : The widget's name. In input widgets, this will also be the
           name of the variable that the form will send to the
           controller. This is the only param that is safe to pass as a
           positional argument to __init__.
template : The template that the widget should use to display itself.
           Currently only Kid templates are supported. You can both
           initialize with a template string or with the path to a
           file-base template: "myapp.templates.widget_tmpl"
default  : Default value to display when no value is passed at display
**params : Keyword arguments specific to your widget or to any of it's
           bases. If listed at class attribute 'params' the will be
           bound automatically to the widget instance.

Note: Do not confuse these parameters with parameters listed at
"params". Some widgets accept parameters at the constructor which are
not listed params, these parameter won't be passed to the template, be
automatically called, etc..

Overrides: object.__init__
(inherited documentation)

get_column(self, name)

source code 

Return DataGrid.Column with specified name.

Raises KeyError if no such column exists.

update_params(self, d)

source code 

Update the template parameters.

This method will have the last chance to update the variables sent to the template for the specific request. All parameters listed at class attribute 'params' will be available at the 'params' dict this method receives.

*Must* call super(MyWidget, self).update_params(params) cooperatively, unless, of course, your know what you're doing. Preferably this should be done before any actual work is done in the method.

Overrides: base.Widget.update_params
(inherited documentation)