Skip to main content

Additional columns for Plone and DataGridField

Project description

An additional set of column types for DatagridField Plone product.

New columns

TextAreaColumn

Like the base Column type, just display a textarea HTML element.

Additional parameters:

rows

Default: 3. Number of rows of the textarea.

cols

Default: 0. Number of columns of the textarea. If not provided the html cols attribute is omitted and an inline style “width: 100%” wil be used instead.

Example:

...
DataGridField('foo',
          columns=("type", "description"),
          widget = DataGridWidget(
                    columns={
                         'type' : Column(_(u"Type")),
                         'description' : TextAreaColumn(_(u"Description"),
                                                        rows=10,
                                                        cols=20),
                    },
         ),
),
...

SelectColumn

Like the default SelectColumn from DataGridField product, but explicitly support the vocabulary_factory way to provide vocabularies.

Additional parameters:

vocabulary_factory

Provide the name of a registered vocabulary using a Zope Component Utility. See the Archetypes Develop Manual for more.

vocabulary

As default SelectColumn, required only if you don’t provide vocabulary_factory. Use this to call a method on the context to obtain the vocabulary.

Example:

...
DataGridField('foo',
          columns=("type", "description"),
          widget = DataGridWidget(
                    columns={
                         'type' : SelectColumn(_(u"Type"),
                                               vocabulary_factory='plone.app.vocabularies.PortalTypes'),
                         'description' : Column(_(u"Description"),),
                    },
         ),
),
...

ReferenceColumn

This is a complex column type that store an unique object “UID”. The default view rendering of this column will display a proper link to the referenced object.

You can use this is different ways. In the simpler example, just use it as a textual column:

...
DataGridField('foo',
          columns=("uid", "comment"),
          widget = DataGridWidget(
                    columns={
                         'uid' : ReferenceColumn(_(u"Reference")),
                         'comment' : Column(_(u"Comment")),
                    },
         ),
),
...

So you are on your own to store a propert UID in the field (not very interesting, isn’t it?).

If you want something more, you can enable an additional JavaScript module and you’ll get an autocomplete feature of referenced objects:

...
DataGridField('foo',
          columns=("uid", "comment"),
          widget = DataGridWidget(
                    helper_js= ('datagridwidget.js', 'datagridautocomplete.js'),
                    columns={
                         'uid' : ReferenceColumn(_(u"Reference")),
                         'comment' : Column(_(u"Comment")),
                    },
         ),
),
...

So you will add to the default datagridwidget.js (automatically provided by the widget) a new datagridautocomplete.js ones. This will also required jQueryUI autocomplete. Please, read also the “Dependencies” section below.

When using autocomplete, you can query Plone in two different way:

  • starting a query with the “/” character will query documents by path, so you can manually surf the whole site.

  • starting as query with other character will perform a full-text query on titles.

Additional parameters:

object_provides

When using the full-text query, only return results of objects that provide those interfaces. Default is an empty list (no filter).

surf_site

Choose to be able to surf the site tree using a “/dir/dir/…” term. Default to True (allowed).

search_site

Choose to be able to search items in the site by full-text query or not. Default to True (allowed).

DateColumn

A simple column field that allows to insert some dates. This field use jQuery UI datepicker plugin.

To use datepicker plugin you need to enable datepicker plugin of jQuery UI (see above for infos) and add an helper_js named datagriddatepicker.js in the widget. See the example below.

Additional parameters:

date_format

Default: yy/mm/dd. The date format to store in the field.

Example:

...
DataGridField('foo',
          columns=("name", "birthday"),
          widget = DataGridWidget(
                    helper_js= ('datagridwidget.js', 'datagriddatepicker.js'),
                    columns={
                         'name' : Column(_(u"Name")),
                         'birthday' : DateColumn(_(u"Birthday"),
                                                 date_format="dd/mm/yy"),
                    },
         ),
),
...

MultiSelectColumn

Based on the SelectColumn from (from this package, not the original ones, so it support the vocabulary_factory parameter), show a list of checkboxes and store a list of selected entries.

Additional parameters: see all parameter from SelectColumn.

Example:

...
DataGridField('foo',
          columns=("recipe_name", "recipe_options"),
          widget = DataGridWidget(
                    helper_js= ('datagridwidget.js', 'datagridwidget_patches.js', 'datagridmultiselect.js'),
                    columns={
                         'recipe_name' : Column(_(u"Name of the recipe"),),
                         'recipe_options' : MultiSelectColumn(_(u"Type"),
                                                              vocabulary_factory='your.vocabulary',
                                                              ),
                    },
         ),
),
...

Dependencies

This product has been tested on:

  • Plone 3.3 and DataGridField 1.6

  • Plone 4.2 and 4.3 and DataGridField 1.9

jQuery version (for Plone 3)

Both ReferenceColumn, DateColumn and MultiSelectColumn need jQuery 1.4.2 or better to work. Plone 3.3 is shipped with jQuery 1.3. You can fix this dependency by your how, or using a 3rd party library.

An alternative Generic Setup import step (”DataGridField: register jQuery 1.4”) is provided with the product. Run this and the default Plone jQuery version will be disabled, then a 1.4.4 version of jQuery will be registered.

Do not run this on Plone 4!

jQueryUI

ReferenceColumn and DateColumn needs that Plone provide jQueryUI library. This product will not cover this requirement, even by dependency.

If you have already jQueryUI (autocomplete or datepicker) behaviour in your Plone site, you are already ok. If you don’t, take a look at collective.jqueryui.autocomplete (or read it’s documentation page to understand how cover this need).

Keep in mind that the standard way of providing jQueryUI support to Plone is by using collective.js.jqueryui

Authors

This product was developed by RedTurtle Technology team.

RedTurtle Technology Site

Credits

Developed with the support of:

All of them supports the PloneGov initiative.

Changelog

0.6.1 (2014-02-06)

  • Soft-support for the field’s title (see pull request 12) [keul]

  • Better implementation of datagridwidget_patches.js approach [keul]

0.6.0 (2014-01-13)

  • Not use jQuery .live() anymore, but switched to .delegate(). We still not use .on() for keeping jQuery 1.4 compatibility. [keul]

  • Added the MultiSelectColumn column [keul]

0.5.1 (2013-12-12)

  • Fixed deprecated usage of jq JavaScript var [davidemoro]

  • Added uninstall profile [keul]

0.5.0 (2013-09-10)

  • Python code now support the new required method that has been added in version 1.9.0. Old DGF versions are still supported [keul]

  • Python code now support the new col_description method that has been added in version 1.9.0. Old DGF versions are still supported [keul]

  • Removed any reference to label_msgid, unused by DataGridField also (see #9) [keul]

0.4.0 (2013-08-20)

  • Added new column: DateColumn, that allows to add date values [cekk]

  • Catch ParseError exceptions [keul]

0.3.2 (2012-10-17)

  • Fixed a bug introduced with version 0.3. See #1 [keul]

0.3.1 (2012-06-27)

  • Fixed manifest and readme [cekk]

0.3.0 (2012-06-27)

  • ReferenceColumn - added base Column default paremeters: default_method, label_msgid, required [cekk]

0.2.0 (2012-01-30)

  • ReferenceColumn - added an alternative jQuery library, installable using a separate Generic Setup profile [keul]

  • ReferenceColumn - fulltext search is now restricted to the path of the calling context [keul]

  • ReferenceColumn - URL where to perform AJAX call is taken from a ICallingContextProvider adapter. 3rd party products can provide a more specific one than the default (that still call the portal url) [keul]

0.1.1 (2012-01-12)

  • ReferenceColumn - fixed bug that when saving empty new row it will save a random site content [keul]

  • ReferenceColumn - Added surf_site and search_site parameters [keul]

0.1.0 (2011-12-01)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.datagridcolumns-0.6.1.zip (72.0 kB view details)

Uploaded Source

File details

Details for the file collective.datagridcolumns-0.6.1.zip.

File metadata

File hashes

Hashes for collective.datagridcolumns-0.6.1.zip
Algorithm Hash digest
SHA256 5704472a84d45a97d2f771027cf8912d73632d9f83cbef208ff3239c1b75445c
MD5 4c369bbcee9fec9d15675b5bd9b32e75
BLAKE2b-256 7a0e17e9d73dc1556f2f899b6a4187ef6762dc629bf167aa38d3c75f8b62145d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page