collective.z3cform.datagridfield 0.13

Version of DataGridField for use with Dexterity / z3c.form

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!

What's new in collective.z3cform.datagridfield 0.11:

  • Be able to use with [vangheem]
Read full changelog
send us
an update
GPL (GNU General Public License) 
Kevin Gill
ROOT \ Internet \ Plone Extensions
collective.z3cform.datagridfield is a Plone product that provides a z3c.form version of the Products.DataGridField. This product was developed for use with Plone4 and Dexterity.


Add collective.z3cforms.datagridfield to your buildout eggs.:


Example usage

This piece of code demonstrates a schema which has a table within it. The layout of the table is defined by a second schema.:

from zope import schema
from zope import interface
from plone.directives import form

form collective.z3cforms.datagridfield import DataGridFieldFactory

class ITableRowSchema(interface.Interface):
 one = schema.TextLine(title=u"One")
 two = schema.TextLine(title=u"Two")
 three = schema.TextLine(title=u"Three")

class IFormSchema(interface.Interface):
 four = schema.TextLine(title=u"Four")
 table = schema.List(title=u"Table"
 value_type=schema.Object(title=u"tablerow", schema=ITableRowSchema))

class EditForm(form.EditForm):

 fields = field.Fields(IFormSchema)
 label=u"Demo Usage of DataGridField"

 fields['table'].widgetFactory = DataGridFieldFactory


The data can be stored as either a list of dicts or a list of objects. In both cases the schema content type is 'schema.Object'.

If you are providing an Object content type (as opposed to dicts) you must provide your own conversion class. The default conversion class returns a list of dicts, not of your object class. See the demos.


The widget can be customised via the updateWidgets method.

 def updateWidgets(self):
 super(EditForm, self).updateWidgets() self.widgets['table'].allow_insert = False # Enable/Disable the insert button on the right self.widgets['table'].allow_delete = False # Enable/Disable the delete button on the right self.widgets['table'].auto_append = False # Enable/Disable the auto-append feature

The widget contains an attribute 'columns' which is manipulated to hide column titles.

Manipulating the Sub-form

The DataGridField makes use of a subform to build each line. The main DataGridField contains a DataGridFieldObject for each line in the table. The DataGridFieldObject in turn creates the DataGridFieldObjectSubForm to store the fields.

There are two callbacks to your main form:

 datagridInitialise(subform, widget)

 * This is called when the subform fields have been initialised, but before the widgets have been created. Field based configuration could occur here.

 datagridUpdateWidgets(subform, widgets, widget)

 * This is called when the subform widgets have been created. At this point, you can configure the widgets, e.g. specify the size of a widget.

Last updated on May 17th, 2012


#DataGridField z3c.form #DataGridField Dexterity #Plone extension #DataGridField #z3c.form #Plone #Dexterity

Add your review!