DataGridField

A table input component for Plone. Uses Javascript to make entering tabular data more user friendly process - there are no round trip HTTP requests to the server when inserting or deleting rows.

Current release
Products.DataGridField 1.6.1

Released Nov 04, 2009 — tested with Plone 3, Plone 2.5

Bug fix.
More about this release…

Download fileGet DataGridField for all platforms (49.6 kB)
Products.DataGridField-1.6.1.tar.gz
Download fileGet DataGridField for all platforms (45.8 kB)
Old-style tarball

Project Description

DataGridField

Released under the GNU General Public License

Features

  • Any number of columns set by a developer
  • Any number of rows filled by a user
  • Insert and deleting rows without submitting a form
  • Many different column types

Requirements

  • A browser with Javascript support. There isn't yet graceful degeneration for browsers without or disabled Javascript.

Quality

  • Tested with Firefox 2.0, IE 6

Usage examples

Simple example with three free text columns:

        schema = BaseSchema + Schema((

        DataGridField('DemoField',
                widget = DataGridWidget(),
                columns=('column1','column2','The third')
                ),
        ))

Complex example with different column types and user friendly labels:

        # Plone imports
        from Products.Archetypes.public import DisplayList
        from Products.Archetypes.public import *

        # Local imports
        from Products.DataGridField import DataGridField, DataGridWidget
        from Products.DataGridField.Column import Column
        from Products.DataGridField.SelectColumn import SelectColumn

        class DataGridDemoType(BaseContent):
            """A simple archetype

            """

            schema = BaseSchema + Schema((
                DataGridField('DemoField',
                        searchable = True,
                        columns=("column1", "column2", "select_sample"),
                        widget = DataGridWidget(
                            columns={
                                'column1' : Column("Toholampi city rox"),
                                'column2' : Column("My friendly name"),
                                'select_sample' : SelectColumn("Friendly name", vocabulary="getSampleVocabulary")
                            },
                         ),
                 ),

                ))

            def getSampleVocabulary(self):
                """
                """
                """ Get list of possible taggable features from ATVocabularyManager """  
                return DisplayList(

                    (("sample", "Sample value 1",),
                    ("sample2", "Sample value 2",),))

For more examples, see unit test code.

Notes

  • Since DataGridField 1.5, if you wish to retain old way of automatic row inserting. Here is a bit logic behind all this - otherwise there will be an extra row added when you edit DGF and press save. o You must set property auto_insert = True to DataGridWidget o You must set property allow_empty_rows = False to DataGridField

Known features

  • Sometimes on Firefox column sizes start changing after the user enters some data. Not sure if this is a Firefox bug, though.
  • Prefilled default values work only for text and select columns
  • Radio button and link column postback is not handled propeply. This needs fixes to very deep into Zope (ZPublisher). If the form validation fails, link column and radio button columns lost their values.

Demo

A demo type is included. Set INSTALL_DEMO_TYPES = True in config.py to enable it. It is disabled by default. This type is neither pretty nor very functional, but demonstrates how a data grid should be used. Also, to run unit tests, you need to set this variable. I couldn't come up with a nice hack which would tell config.py whether it's imported from unit testing framework or not.

References

Custom Search product uses DataGridField for editing search form query fields.

London School of Marketing site uses DataGridField extensively

Contributors

People who have been making this true:

  • Mikko Ohtamaa, Red Innovation
  • Danny Bloemendaal
  • Radim Novotny
  • Justin Ryan
  • Alexander Limi
  • Jarn
  • Martin Aspeli
  • Paul Everitt
  • Development was helped by Vincent Bonamy

Original concept and prototype:

  • Geir Bækholt, Jarn
  • Paul Everitt, Zope Europe Association

Sponsorship

Organizations paying up for the development