Introduction
============
Provides a field with a datagrid (table), where each row is a sub form.
It is a `z3c.form <https://z3cform.readthedocs.io/en/latest/>`_ implementation of the `Products.DataGridField <http://plone.org/products/datagridfield>`_ .
This product was developed for use with Plone and Dexterity.
.. image:: https://github.com/collective/collective.z3cform.datagridfield/actions/workflows/test.yml/badge.svg
:target: https://github.com/collective/collective.z3cform.datagridfield/actions/workflows/test.yml
Installation
============
Add collective.z3cform.datagridfield to your buildout eggs:
.. code-block:: ini
[buildout]
...
eggs =
collective.z3cform.datagridfield
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:
.. code-block:: python
from collective.z3cform.datagridfield.datagridfield import DataGridFieldFactory
from collective.z3cform.datagridfield.row import DictRow
from plone.autoform.directives import widget
from plone.autoform.form import AutoExtensibleForm
from z3c.form import form
from zope import interface
from zope import schema
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=DictRow(
title=u"tablerow",
schema=ITableRowSchema,
),
)
widget(table=DataGridFieldFactory)
class EditForm(AutoExtensibleForm, form.EditForm):
label=u"Demo Usage of DataGridField"
schema = IFormSchema
And configured via zcml:
.. code-block:: xml
<browser:page
name="editform--example"
class=".editform.EditForm"
for="*"
permission="zope2.View"
/>
Also it can be used from a supermodel XML:
.. code-block:: xml
<field name="table" type="zope.schema.List">
<description/>
<title>Table</title>
<value_type type="collective.z3cform.datagridfield.DictRow">
<schema>your.package.interfaces.ITableRowSchema</schema>
</value_type>
<form:widget type="collective.z3cform.datagridfield.datagridfield.DataGridFieldFactory"/>
</field>
Storage
-------
The data can be stored as either a list of dicts or a list of objects.
If the data is a list of dicts, the value_type is DictRow.
Otherwise, the value_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.
Configuration
=============
Row editor handles
------------------
Widget parameters can be passed via widget hints. Extended schema example from above:
.. code-block:: python
class IFormSchema(interface.Interface):
four = schema.TextLine(title=u"Four")
table = schema.List(
title=u"Table",
value_type=DictRow(
title=u"tablerow",
schema=ITableRowSchema,
),
)
widget(
"table",
DataGridFieldFactory,
allow_insert=False,
allow_delete=False,
allow_reorder=False,
auto_append=False,
display_table_css_class="table table-striped",
input_table_css_class="table table-sm",
)
Manipulating the Sub-form
-------------------------
The `DictRow` schema can also be extended via widget hints. Extended schema examples from above:
.. code-block:: python
from z3c.form.browser.checkbox import CheckBoxFieldWidget
class ITableRowSchema(interface.Interface):
two = schema.TextLine(title=u"Level 2")
address_type = schema.Choice(
title="Address Type",
required=True,
values=["Work", "Home"],
)
# show checkboxes instead of selectbox
widget(address_type=CheckBoxFieldWidget)
class IFormSchema(interface.Interface):
table = schema.List(
title=u"Nested selection tree test",
value_type=DictRow(
title=u"tablerow",
schema=ITableRowSchema
)
)
widget(table=DataGridFieldFactory)
Working with plone.app.registry
-------------------------------
To use the field with plone.app.registry, you'll have to use
a version of the field that has PersistentField as it's base
class:
.. code-block:: python
from collective.z3cform.datagridfield.registry import DictRow
JavaScript events
-----------------
``collective.z3cform.datagridfield`` fires jQuery events,
so that you can hook them in your own Javascript for DataGridField
behavior customization.
The following events are currently fired against ``table.datagridwidget-table-view``
* ``beforeaddrow`` [datagridfield, newRow]
* ``afteraddrow`` [datagridfield, newRow]
* ``beforeaddrowauto`` [datagridfield, newRow]
* ``afteraddrowauto`` [datagridfield, newRow]
* ``aftermoverow`` [datagridfield]
* ``afterdatagridfieldinit`` - All DGFs on the page have been initialized
Example usage:
.. code-block:: javascript
var handleDGFInsert = function(event, dgf, row) {
row = $(row);
console.log("Got new row:");
console.log(row);
};
// Bind all DGF handlers on the page
$(document).on('beforeaddrow beforeaddrowauto', '.datagridwidget-table-view', handleDGFInsert);
Demo
====
More examples are in the demo subfolder of this package.
Versions
========
* Version 3.x is Plone 6+ only (z3c.form >= 4)
* Versions 1.4.x and 2.x are for Plone 5.x,
* Versions 1.3.x is for Plone 4.3
* For Python 3.7 at least PyYAML 4.2b1
Requirements
============
* z3c.forms
* A browser with javascript support
* jquery 1.4.3 or later
Changelog
=========
.. You should *NOT* be adding new change log entries to this file.
You should create a file in the news directory instead.
For helpful instructions, please see:
https://github.com/plone/plone.releaser/blob/master/ADD-A-NEWS-ITEM.rst
.. towncrier release notes start
3.0.3 (2024-11-05)
------------------
Bug fixes:
- fix the DictRowConverter when the field schema changes fields and no value
for the new column field is available yet.
[petschki] (#0)
- For the JSON deserializer, skip empty values from non-required fields.
This fixes a problem where empty non-required fields would break deserialization.
[thet] (#184)
- Fix bug in vocabulary lookup on `++add++` forms. Override `IFieldPermissionChecker`
the same as for `IDexterityContent`.
[petschki] (#187)
- Add missing `plone.autoform` exportimport handler.
[petschki] (#188)
- Changed the registry.xml to use "plone.base.interfaces.resources.IBundleRegistry" instead of "Products.CMFPlone.interfaces.IBundleRegistry"
[cihanandac] (#193)
- Upgrade JS resources.
[petschki] (#193)
- Fix bug when pattern class is not the first one, after adding a new row.
[frapell] (#198)
Internal:
- configure with `plone/meta`.
[petschki] (#0)
3.0.2 (2023-09-11)
------------------
- Update JS Resources.
[petschki]
3.0.1 (2023-06-27)
------------------
- fix `readonly` fields in `DictRowConverter.toFieldValue`.
[petschki]
- Remove obsolete `GridDataConverter` and use default `z3c.form.converter.MultiConverter`.
This now calls the `DictRowConverter` and translates all columns to their correct widget/field value.
[petschki]
- Add JSON deserializer for `plone.restapi`.
[petschki]
3.0.0 (2022-09-28)
------------------
- Latest mockup and `mf_config` updates.
[petschki]
- Fix data converters when the row schema is set via autoform hints.
[petschki]
- Customizable input widget table css class.
[petschki]
3.0.0a1 (2022-06-28)
--------------------
- Upgrade to Plone 6 only, with newest z3c.form and module federation.
[petschki]
2.0.2 (2022-03-14)
------------------
- Scan and init row ui after inserting the row into the DOM tree.
Should prevent JS initialization errors.
[thet]
- When creating rows clone the row without any attached event handlers.
[thet]
- Set auto-append UI state only for auto-append mode.
[thet]
- Merge member-only JavaScript with logged-in bundle, not default bundle.
[thet]
- Remove unused ``init_field.js`` script.
[thet]
- Use latest config for Github Actions and tox. Add Plone 6 related ci and tox config.
[thomasmassmann]
2.0.1 (2021-07-28)
------------------
- Amend fix for `#110 <https://github.com/collective/collective.z3cform.datagridfield/issues/110>`_ in registry.
[agitator]
- Fix documentation. `#110 <https://github.com/collective/collective.z3cform.datagridfield/issues/110>`_.
[petschki]
2.0 (2021-03-29)
----------------
- Register new pat-datagridfield bundle.
Breaking change:
The JavaScript resources have changed a lot.
Please run the provided upgrade steps!
If you were customizing templates which loaded these JavaScript resources
or customized the JavaScript functionality itself, take special care.
The bundle is loaded only for logged-in users.
- Rework JavaScript as a Pattern for better initialization.
- Row UI buttons optimizations
Change row UI elements from anchor to buttons for better semantics.
Fix Bootstrap classes, remove unused attributes, add a title to buttons.
[thet]
- Change UI element classes
Remove non-unique id attributes from UI buttons and add classes instead.
Let the button functionality be initialized by the pattern.
Breaking change:
In this version a pattern handles all the JavaScript functionality to ensure best possible encapsulation between different instances of the datagridfield widget.
If you have customized templates, make sure you do the following:
- Add the class ``pat-datagridfield`` to the ``datagridwidget-table-view`` nodes (datagridfield_input.pt, datagridfield_input_block.pt).
- Add the following classes instead of ids to the ui buttons as shown in this map (datagridfieldobject_input.pt, datagridfieldobject_input_block.pt):
- #btn-addrow -> .dgf--row-add
- #btn-deleterow -> .dgf--row-delete
- #btn-moveup -> .dgf--row-moveup
- #btn-movedown -> .dgf--row-movedown
[thet]
- Use pat-datagridfield in templates.
[thet]
- Remove extra parameter for datagridfield widget as it was unused and untested.
[thet]
- Clean up upgrade profile definitions and align to Plone standards.
[thet]
- Use Github actions instead Travis CI.
[thet]
- Test setup using bobtemplate.plone config.
[thet]
- Code formatting - black, zpretty, prettier.
[thet]
- Import with module name.
[ksuess]
- Register translations in locales directory.
[erral]
- Add es and eu translations.
[erral]
- Accessibility fixes.
[erral]
1.5.3 (2020-03-03)
------------------
- Bug fix for multiple datagridfields per form.
Multiple lines were auto added when more than one datagrid was present.
Fixes `issue 96 <https://github.com/collective/collective.z3cform.datagridfield/issues/96>`_.
[maurits]
1.5.2 (2020-01-07)
------------------
- Fix "Unknown directive widgetTemplate"
[agitator]
- Bug fix: auto appending row.
[ksuess]
1.5.1 (2019-03-21)
------------------
- Add missing upgrade profile to_2
[agitator]
1.5.0 (2019-03-09)
------------------
- Add support for Python 3 and Plone 5.2.
[pbauer, agitator]
1.4.0 (2019-02-21)
------------------
- Drop support for Plone 4.
[pbauer]
- Use Ressource-Registry (Pat-Registry), Update JS/CSS, Add Uninstall
[2silver]
- use Plone5 glyphicons instead of images
[2silver]
- Added missing upgrade step, calling browserlayer setup.
[sgeulette]
- Display column description if provided in schema `field.description`.
[gbastien, bleybaert]
- Specify in README.rst that versions >= 1.4 are for Plone 5+ and
versions < 1.4 are for Plone 4.
[gbastien]
- Usability change: add an (hidden) label inside the add commands
[keul]
- Compatibility with Plone 5 modals/overlay from mockup
[keul]
1.3.1 (2019-02-21)
------------------
- Extend uninstall profile.
[thet]
- Wrapped commands inside ``A`` tags, required for accessibility reason (change backported from Products.DataGridField).
This also simplify customizing icons with pure CSS.
[keul]
- Replaced minus icon with a more usable delete icon.
[keul]
- Removed ols-school ``*`` chars for marking fields as required.
[keul]
- Fix object access
[tomgross]
- Fix usage of related items widget in subforms
https://github.com/plone/Products.CMFPlone/issues/2446
[tomgross]
1.3.0 (2017-11-22)
------------------
- Set widget mode on cell widget in order to support autoform mode directive. [jone]
- Bugfix: do not try to update readonly fields. [jone]
- Cleanup: utf8 headers, isort, code-style. [jensens]
- Remove dependency on plone.directives.form in setup.py,
it was not used any longer. [jensens]
- Feature/Fix: Support widgets using patternslib in a DictRow.
[jensens]
- Fix: #36 remove grok from all documentation since grok is no longer supported.
[jensens]
- Copy relevant parts of ObjectSubform from z3c.form 3.2.10 over here, it was removed in later versions.
[jensens]
- Add Browserlayer and use it, also add uninstall step.
[jensens]
- Move Demo package to in here.
[jensens]
1.2 (2017-03-08)
----------------
- Fix validation exception on readonly fields.
[rodfersou]
- Fix bug for widget.klass is NonType in the block view when defining the class for the field.
- Allow deletion of last row in non-auto-append mode.
[gaudenz]
- fixed binding for IChoice fields during validation [djay]
- plone 5 compatibility and fixed travis testing for plone 5 [djay]
1.1 (2014-07-25)
----------------
- Removed JS code that relies on firefox being used.
[neilferreira]
- Stopped referencing the 'event' element when creating a new row as the event
that triggered the content of an input changing may have been from another element.
[neilferreira]
1.0 (2014-06-02)
----------------
- Add 'form-widgets-field_id' as widget css id (consistency with other widgets).
[thomasdesvenain]
- Fix package dependencies.
[hvelarde]
- Use BlockDataGridFieldObject for rows in a BlockDataGridField.
[gaudenz]
- Filter out any auto append or template rows in updateWidgets.
[gaudenz]
- Add row parameter to aftermoverow JS event
[gaudenz]
- Don't reset class attribute on cloned template rows
[gaudenz]
- Replace row index in all template row elements, not just input elements.
Replace the index in id, name, for, href and data-fieldname attributes
when cloning the template row.
[gaudenz]
0.15 (2013-09-24)
-----------------
- Added possibility to define the CSS class for the main table when the field is displayed.
This way, you can use common Plone existing classes (like 'listing').
[gbastien]
- Fixed auto-append bug when there is more than one datagrid field in page auto-appending one field binds
"change.dgf" to another field also. added "$(dgf).find(.." in datagridfield.js line 138 so it binds to right element only.
[tareqalam]
- Only abort moveRow if the row is really not found and not if the row idx just happens to be 0.
[gaudenz]
- Also update hidden data rows when reindexing in row mode. This fix was previously somehow only done for block mode.
[gaudenz]
- Relax requirements for markup, don't assume inputs are direct children of table cells. This makes using custom
templates much easier.
[gaudenz]
- Fix validate function signature for IValidator API. The API requires a "force" argument.
[gaudenz]
- Register the SubformAdapter for IPloneForm layer to avoid that the Adapter from plone.app.z3cform
takes precedence.
[gaudenz]
0.14 (2013-05-24)
-----------------
- Align travis setup to other packages.
[saily]
- Add new V1 ``bootstrap.py``.
[saily]
- Added CSS classes to tbody rows (``row-(1...n)``) and thead columns
(``cell-(1...m)``) to allow more styling in edit forms.
[saily]
- Fixed wrong template in display mode when set editing to block edit mode [miohtama]
- Added CSS classes (widget.klass attribute) for DataGridField, to separate it from other MultiWidgets [miohtama]
0.13 (2013-04-09)
-----------------
- Add travis-ci configs [jaroel]
- Convert tests to plone.app.testing [jaroel]
- Fix to expect ``zope.schema.interfaces.ValidationError`` to work better
with *TooLong* and *TooShort* exceptions. [datakurre]
- Fix IE7 failing on `<label>` for manipulation [miohtama]
- Deal with situations where there is zero rows on DGF and no auto-append row available [miohtama]
- Correctly bind DGF events on DOM content loaded, not when Javascript is parsed [miohtama]
- Don't display movement handles if the row cannot be moved [miohtama]
- Changed move up and down handlers to stay in fixed positions to make cells stay in the same width regardless of moving [miohtama]
- Fixed checkbox saving, was broken by nested DGF support [miohtama]
- Added block edit mode [miohtama]
- "use strict;" and ECMAScript 5 compatible Javascript clean-up [miohtama]
- Added *afterrowmoved* JS event [miohtama]
0.12 (2012-10-30)
--------------------
- Updated empty row selection. [jstegle]
- Nested DataGridField support (yo dawg...) [miohtama]
- Support plone.autoform and grok'ed row schemas [miohtama]
- Added ``DataGridField.extra`` parameter, so you can pass out
application specific data to Javascript [miohtama]
0.11 (2012-05-16)
-----------------
- be able to use with plone.app.registry
[vangheem]
0.10 (2012-02-12)
-----------------
- Fix bug with moving the last row up.
[m-martinez]
0.9 (2011-10-27)
----------------
- Clone events when adding new row - fixes bug where browse button of
plone.formwidget.contenttree did nothing for new rows
[anthonygerrard]
- Reindex more indexed attributes of cloned row
[anthonygerrard]
0.8 (2011-09-24)
----------------
- Avoid using the "row" CSS class.
[davisagli]
- Fixes to work with jQuery 1.3.x (use .remove() instead of .detach(), fetch data
attributes a different way, and avoid live binding the change event).
[davisagli]
- Don't error out when getting a ``FormatterValidationError``, pass
it on to z3c.form instead.
[claytron]
- Give manipulator images a relative src rather than absolute. This
previously meant the widget didn't work on sites without Plone/Zope at the
root of the domain.
[davidjb]
- During auto-insert, add our new row into the document first, before reindexing
it and changing its elements' IDs. This allows Javascript that depends on
these IDs (such as plone.formwidget.autocomplete) to pick up the correct
fields.
[davidjb]
- Tidying up and reducing complexity of auto-insert functionality
[davidjb]
- Removing unnecessary auto-insert bind and unbind as this is already covered
by jQuery's `live()` function against the `auto-append` class. Adding/removing
this class against rows automatically does this.
[davidjb]
- Resolved issue with auto-insert functionality not working by removing
table-specific check in Javascript.
[davidjb]
0.7 (2011-07-01)
----------------
- Changed markup/javascript to prevent duplicate HTML id attributes. Changed
Javascript to allow for datagrid page templates that don't use tables.
[dextermilo]
- Improve spacing in CSS.
[davisagli]
- Revert my fix to ensure that blank rows are added, because it duplicated
a fix in z3c.form resulting in extra rows.
[davisagli]
0.6 (2011-05-17)
----------------
- Search for datagridInitialise and datagridUpdateWidgets on the
parent form, also when in a fieldset.
[maurits]
- Register templates on plone.app.z3cform.interfaces.IPloneFormLayer to
take precedence over that packages list widget templates.
[elro]
- Make sure that updateWidgets is called to add blank rows even if the
widget has no value.
[davisagli]
- When extracting a row value fails due to a validation error, convert
widget values to field values so the value can be successfully applied
to the grid widget.
[davisagli]
- Register a plone.supermodel handler for the DictRow so it can be used
in supermodel models.
[davisagli]
- Depend on collective.z3cform.datagridfield_demo as a test extra;
use the browser view from this package in the tests.
[maurits]
- _validate still used when import/exporting, fix up code so it works
[lentinj]
- Add a DictRow serializer for transmogrify.dexterity
[lentinj]
- Only use width:100% on input cells that are the only element in the cell
[lentinj]
- Reorder row indices backwards when adding rows. This means that adjacent
rows don't share the same index temporarily, for example:-
- Row 1 and 2 contain input:radio based widgets
- Row 0 added, row renumbering starts
- Row 1 widgets renamed 2
- Both sets of input:radio share the same name, one deselected
- Row 2 widgets renamed 3
- . . .
[lentinj]
- Use jQuery to clone rows, and clone the jQuery events on the rows.
[lentinj]
- Implemented reorder functionality
0.5 (2011-02-08)
----------------
- Put in the DictRow class (tks Martin Aspeli)
- Moved the demo code out to a separate package collective.z3cform.datagridfield_demo
(tks Laurence Rowe).
- Removed superfluous lines from setup.py (tks Laurence Rowe).
- Removed unnecessary dependency on dexterity (tks Laurence Rowe).
- Removed unnecessary dependency on grok (tks Laurence Rowe).
0.4 (2011-02-06)
----------------
- Renamed the demo pages. The starting point is now @@demo-collective.z3cform.datagrid .
- The widget can now be configured via the updateWidgets method. It
is no longer necessary to create a custom factory.
- The columns can now be omitted.
- Provide a set of demo views for Object access.
0.3 (2011-02-04)
----------------
- The auto-append functionality did not bind correctly for popup forms.
I switched to using jQuery.live() instead of binding at document load time.
- Added a menu to the demo pages
- Added a display only form option.
- Fixed the restructured text of the main README.txt so that it will show
more friendly in PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/collective/collective.z3cform.datagridfield",
"name": "collective.z3cform.datagridfield",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "plone z3cform table data grid",
"author": "Kevin Gill",
"author_email": "kevin@movieextras.se",
"download_url": "https://files.pythonhosted.org/packages/2b/69/fb5f0e9828b25fe946b3f65c83e4a8e7618de17252c377b71361ceb5d4a3/collective_z3cform_datagridfield-3.0.3.tar.gz",
"platform": null,
"description": "Introduction\n============\n\nProvides a field with a datagrid (table), where each row is a sub form.\n\nIt is a `z3c.form <https://z3cform.readthedocs.io/en/latest/>`_ implementation of the `Products.DataGridField <http://plone.org/products/datagridfield>`_ .\n\nThis product was developed for use with Plone and Dexterity.\n\n.. image:: https://github.com/collective/collective.z3cform.datagridfield/actions/workflows/test.yml/badge.svg\n :target: https://github.com/collective/collective.z3cform.datagridfield/actions/workflows/test.yml\n\n\nInstallation\n============\n\nAdd collective.z3cform.datagridfield to your buildout eggs:\n\n.. code-block:: ini\n\n [buildout]\n ...\n eggs =\n collective.z3cform.datagridfield\n\n\nExample usage\n=============\n\nThis piece of code demonstrates a schema which has a table within it.\nThe layout of the table is defined by a second schema:\n\n.. code-block:: python\n\n from collective.z3cform.datagridfield.datagridfield import DataGridFieldFactory\n from collective.z3cform.datagridfield.row import DictRow\n from plone.autoform.directives import widget\n from plone.autoform.form import AutoExtensibleForm\n from z3c.form import form\n from zope import interface\n from zope import schema\n\n\n class ITableRowSchema(interface.Interface):\n one = schema.TextLine(title=u\"One\")\n two = schema.TextLine(title=u\"Two\")\n three = schema.TextLine(title=u\"Three\")\n\n\n class IFormSchema(interface.Interface):\n four = schema.TextLine(title=u\"Four\")\n table = schema.List(\n title=u\"Table\",\n value_type=DictRow(\n title=u\"tablerow\",\n schema=ITableRowSchema,\n ),\n )\n\n widget(table=DataGridFieldFactory)\n\n\n class EditForm(AutoExtensibleForm, form.EditForm):\n label=u\"Demo Usage of DataGridField\"\n schema = IFormSchema\n\n\nAnd configured via zcml:\n\n.. code-block:: xml\n\n <browser:page\n name=\"editform--example\"\n class=\".editform.EditForm\"\n for=\"*\"\n permission=\"zope2.View\"\n />\n\n\nAlso it can be used from a supermodel XML:\n\n.. code-block:: xml\n\n <field name=\"table\" type=\"zope.schema.List\">\n <description/>\n <title>Table</title>\n <value_type type=\"collective.z3cform.datagridfield.DictRow\">\n <schema>your.package.interfaces.ITableRowSchema</schema>\n </value_type>\n <form:widget type=\"collective.z3cform.datagridfield.datagridfield.DataGridFieldFactory\"/>\n </field>\n\n\nStorage\n-------\n\nThe data can be stored as either a list of dicts or a list of objects.\nIf the data is a list of dicts, the value_type is DictRow.\nOtherwise, the value_type is 'schema.Object'.\n\nIf you are providing an Object content type (as opposed to dicts) you must provide your own conversion class.\nThe default conversion class returns a list of dicts,\nnot of your object class.\nSee the demos.\n\n\nConfiguration\n=============\n\n\nRow editor handles\n------------------\n\nWidget parameters can be passed via widget hints. Extended schema example from above:\n\n.. code-block:: python\n\n class IFormSchema(interface.Interface):\n four = schema.TextLine(title=u\"Four\")\n table = schema.List(\n title=u\"Table\",\n value_type=DictRow(\n title=u\"tablerow\",\n schema=ITableRowSchema,\n ),\n )\n\n widget(\n \"table\",\n DataGridFieldFactory,\n allow_insert=False,\n allow_delete=False,\n allow_reorder=False,\n auto_append=False,\n display_table_css_class=\"table table-striped\",\n input_table_css_class=\"table table-sm\",\n )\n\n\n\nManipulating the Sub-form\n-------------------------\n\nThe `DictRow` schema can also be extended via widget hints. Extended schema examples from above:\n\n.. code-block:: python\n\n from z3c.form.browser.checkbox import CheckBoxFieldWidget\n\n\n class ITableRowSchema(interface.Interface):\n\n two = schema.TextLine(title=u\"Level 2\")\n\n address_type = schema.Choice(\n title=\"Address Type\",\n required=True,\n values=[\"Work\", \"Home\"],\n )\n # show checkboxes instead of selectbox\n widget(address_type=CheckBoxFieldWidget)\n\n\n class IFormSchema(interface.Interface):\n\n table = schema.List(\n title=u\"Nested selection tree test\",\n value_type=DictRow(\n title=u\"tablerow\",\n schema=ITableRowSchema\n )\n )\n widget(table=DataGridFieldFactory)\n\n\nWorking with plone.app.registry\n-------------------------------\n\nTo use the field with plone.app.registry, you'll have to use\na version of the field that has PersistentField as it's base\nclass:\n\n.. code-block:: python\n\n from collective.z3cform.datagridfield.registry import DictRow\n\n\nJavaScript events\n-----------------\n\n``collective.z3cform.datagridfield`` fires jQuery events,\nso that you can hook them in your own Javascript for DataGridField\nbehavior customization.\n\nThe following events are currently fired against ``table.datagridwidget-table-view``\n\n* ``beforeaddrow`` [datagridfield, newRow]\n\n* ``afteraddrow`` [datagridfield, newRow]\n\n* ``beforeaddrowauto`` [datagridfield, newRow]\n\n* ``afteraddrowauto`` [datagridfield, newRow]\n\n* ``aftermoverow`` [datagridfield]\n\n* ``afterdatagridfieldinit`` - All DGFs on the page have been initialized\n\nExample usage:\n\n.. code-block:: javascript\n\n var handleDGFInsert = function(event, dgf, row) {\n row = $(row);\n console.log(\"Got new row:\");\n console.log(row);\n };\n\n // Bind all DGF handlers on the page\n $(document).on('beforeaddrow beforeaddrowauto', '.datagridwidget-table-view', handleDGFInsert);\n\n\nDemo\n====\n\nMore examples are in the demo subfolder of this package.\n\n\nVersions\n========\n\n* Version 3.x is Plone 6+ only (z3c.form >= 4)\n* Versions 1.4.x and 2.x are for Plone 5.x,\n* Versions 1.3.x is for Plone 4.3\n* For Python 3.7 at least PyYAML 4.2b1\n\n\nRequirements\n============\n\n* z3c.forms\n* A browser with javascript support\n* jquery 1.4.3 or later\n\n\n\nChangelog\n=========\n\n.. You should *NOT* be adding new change log entries to this file.\n You should create a file in the news directory instead.\n For helpful instructions, please see:\n https://github.com/plone/plone.releaser/blob/master/ADD-A-NEWS-ITEM.rst\n\n.. towncrier release notes start\n\n3.0.3 (2024-11-05)\n------------------\n\nBug fixes:\n\n\n- fix the DictRowConverter when the field schema changes fields and no value\n for the new column field is available yet.\n [petschki] (#0)\n- For the JSON deserializer, skip empty values from non-required fields.\n This fixes a problem where empty non-required fields would break deserialization.\n [thet] (#184)\n- Fix bug in vocabulary lookup on `++add++` forms. Override `IFieldPermissionChecker`\n the same as for `IDexterityContent`.\n [petschki] (#187)\n- Add missing `plone.autoform` exportimport handler.\n [petschki] (#188)\n- Changed the registry.xml to use \"plone.base.interfaces.resources.IBundleRegistry\" instead of \"Products.CMFPlone.interfaces.IBundleRegistry\"\n [cihanandac] (#193)\n- Upgrade JS resources.\n [petschki] (#193)\n- Fix bug when pattern class is not the first one, after adding a new row.\n [frapell] (#198)\n\n\nInternal:\n\n\n- configure with `plone/meta`.\n [petschki] (#0)\n\n\n3.0.2 (2023-09-11)\n------------------\n\n- Update JS Resources.\n [petschki]\n\n\n3.0.1 (2023-06-27)\n------------------\n\n- fix `readonly` fields in `DictRowConverter.toFieldValue`.\n [petschki]\n\n- Remove obsolete `GridDataConverter` and use default `z3c.form.converter.MultiConverter`.\n This now calls the `DictRowConverter` and translates all columns to their correct widget/field value.\n [petschki]\n\n- Add JSON deserializer for `plone.restapi`.\n [petschki]\n\n\n3.0.0 (2022-09-28)\n------------------\n\n- Latest mockup and `mf_config` updates.\n [petschki]\n\n- Fix data converters when the row schema is set via autoform hints.\n [petschki]\n\n- Customizable input widget table css class.\n [petschki]\n\n\n3.0.0a1 (2022-06-28)\n--------------------\n\n- Upgrade to Plone 6 only, with newest z3c.form and module federation.\n [petschki]\n\n\n2.0.2 (2022-03-14)\n------------------\n\n- Scan and init row ui after inserting the row into the DOM tree.\n Should prevent JS initialization errors.\n [thet]\n\n- When creating rows clone the row without any attached event handlers.\n [thet]\n\n- Set auto-append UI state only for auto-append mode.\n [thet]\n\n- Merge member-only JavaScript with logged-in bundle, not default bundle.\n [thet]\n\n- Remove unused ``init_field.js`` script.\n [thet]\n\n- Use latest config for Github Actions and tox. Add Plone 6 related ci and tox config.\n [thomasmassmann]\n\n\n2.0.1 (2021-07-28)\n------------------\n\n- Amend fix for `#110 <https://github.com/collective/collective.z3cform.datagridfield/issues/110>`_ in registry.\n [agitator]\n\n- Fix documentation. `#110 <https://github.com/collective/collective.z3cform.datagridfield/issues/110>`_.\n [petschki]\n\n\n2.0 (2021-03-29)\n----------------\n\n- Register new pat-datagridfield bundle.\n\n Breaking change:\n The JavaScript resources have changed a lot.\n Please run the provided upgrade steps!\n\n If you were customizing templates which loaded these JavaScript resources\n or customized the JavaScript functionality itself, take special care.\n The bundle is loaded only for logged-in users.\n\n- Rework JavaScript as a Pattern for better initialization.\n\n- Row UI buttons optimizations\n Change row UI elements from anchor to buttons for better semantics.\n Fix Bootstrap classes, remove unused attributes, add a title to buttons.\n [thet]\n\n- Change UI element classes\n\n Remove non-unique id attributes from UI buttons and add classes instead.\n Let the button functionality be initialized by the pattern.\n\n Breaking change:\n In this version a pattern handles all the JavaScript functionality to ensure best possible encapsulation between different instances of the datagridfield widget.\n If you have customized templates, make sure you do the following:\n\n - Add the class ``pat-datagridfield`` to the ``datagridwidget-table-view`` nodes (datagridfield_input.pt, datagridfield_input_block.pt).\n - Add the following classes instead of ids to the ui buttons as shown in this map (datagridfieldobject_input.pt, datagridfieldobject_input_block.pt):\n\n - #btn-addrow -> .dgf--row-add\n - #btn-deleterow -> .dgf--row-delete\n - #btn-moveup -> .dgf--row-moveup\n - #btn-movedown -> .dgf--row-movedown\n\n [thet]\n\n- Use pat-datagridfield in templates.\n [thet]\n\n- Remove extra parameter for datagridfield widget as it was unused and untested.\n [thet]\n\n- Clean up upgrade profile definitions and align to Plone standards.\n [thet]\n\n- Use Github actions instead Travis CI.\n [thet]\n\n- Test setup using bobtemplate.plone config.\n [thet]\n\n- Code formatting - black, zpretty, prettier.\n [thet]\n\n- Import with module name.\n [ksuess]\n\n- Register translations in locales directory.\n [erral]\n\n- Add es and eu translations.\n [erral]\n\n- Accessibility fixes.\n [erral]\n\n\n1.5.3 (2020-03-03)\n------------------\n\n- Bug fix for multiple datagridfields per form.\n Multiple lines were auto added when more than one datagrid was present.\n Fixes `issue 96 <https://github.com/collective/collective.z3cform.datagridfield/issues/96>`_.\n [maurits]\n\n\n1.5.2 (2020-01-07)\n------------------\n\n- Fix \"Unknown directive widgetTemplate\"\n [agitator]\n\n- Bug fix: auto appending row.\n [ksuess]\n\n\n1.5.1 (2019-03-21)\n------------------\n\n- Add missing upgrade profile to_2\n [agitator]\n\n\n1.5.0 (2019-03-09)\n------------------\n\n- Add support for Python 3 and Plone 5.2.\n [pbauer, agitator]\n\n\n1.4.0 (2019-02-21)\n------------------\n\n- Drop support for Plone 4.\n [pbauer]\n\n- Use Ressource-Registry (Pat-Registry), Update JS/CSS, Add Uninstall\n [2silver]\n\n- use Plone5 glyphicons instead of images\n [2silver]\n\n- Added missing upgrade step, calling browserlayer setup.\n [sgeulette]\n\n- Display column description if provided in schema `field.description`.\n [gbastien, bleybaert]\n\n- Specify in README.rst that versions >= 1.4 are for Plone 5+ and\n versions < 1.4 are for Plone 4.\n [gbastien]\n\n- Usability change: add an (hidden) label inside the add commands\n [keul]\n\n- Compatibility with Plone 5 modals/overlay from mockup\n [keul]\n\n1.3.1 (2019-02-21)\n------------------\n\n- Extend uninstall profile.\n [thet]\n\n- Wrapped commands inside ``A`` tags, required for accessibility reason (change backported from Products.DataGridField).\n This also simplify customizing icons with pure CSS.\n [keul]\n\n- Replaced minus icon with a more usable delete icon.\n [keul]\n\n- Removed ols-school ``*`` chars for marking fields as required.\n [keul]\n\n- Fix object access\n [tomgross]\n\n- Fix usage of related items widget in subforms\n https://github.com/plone/Products.CMFPlone/issues/2446\n [tomgross]\n\n1.3.0 (2017-11-22)\n------------------\n\n- Set widget mode on cell widget in order to support autoform mode directive. [jone]\n\n- Bugfix: do not try to update readonly fields. [jone]\n\n- Cleanup: utf8 headers, isort, code-style. [jensens]\n\n- Remove dependency on plone.directives.form in setup.py,\n it was not used any longer. [jensens]\n\n- Feature/Fix: Support widgets using patternslib in a DictRow.\n [jensens]\n\n- Fix: #36 remove grok from all documentation since grok is no longer supported.\n [jensens]\n\n- Copy relevant parts of ObjectSubform from z3c.form 3.2.10 over here, it was removed in later versions.\n [jensens]\n\n- Add Browserlayer and use it, also add uninstall step.\n [jensens]\n\n- Move Demo package to in here.\n [jensens]\n\n\n1.2 (2017-03-08)\n----------------\n\n- Fix validation exception on readonly fields.\n [rodfersou]\n- Fix bug for widget.klass is NonType in the block view when defining the class for the field.\n- Allow deletion of last row in non-auto-append mode.\n [gaudenz]\n- fixed binding for IChoice fields during validation [djay]\n- plone 5 compatibility and fixed travis testing for plone 5 [djay]\n\n\n1.1 (2014-07-25)\n----------------\n\n- Removed JS code that relies on firefox being used.\n [neilferreira]\n\n- Stopped referencing the 'event' element when creating a new row as the event\n that triggered the content of an input changing may have been from another element.\n [neilferreira]\n\n\n1.0 (2014-06-02)\n----------------\n\n- Add 'form-widgets-field_id' as widget css id (consistency with other widgets).\n [thomasdesvenain]\n\n- Fix package dependencies.\n [hvelarde]\n\n- Use BlockDataGridFieldObject for rows in a BlockDataGridField.\n [gaudenz]\n\n- Filter out any auto append or template rows in updateWidgets.\n [gaudenz]\n\n- Add row parameter to aftermoverow JS event\n [gaudenz]\n\n- Don't reset class attribute on cloned template rows\n [gaudenz]\n\n- Replace row index in all template row elements, not just input elements.\n Replace the index in id, name, for, href and data-fieldname attributes\n when cloning the template row.\n [gaudenz]\n\n\n0.15 (2013-09-24)\n-----------------\n\n- Added possibility to define the CSS class for the main table when the field is displayed.\n This way, you can use common Plone existing classes (like 'listing').\n [gbastien]\n\n- Fixed auto-append bug when there is more than one datagrid field in page auto-appending one field binds\n \"change.dgf\" to another field also. added \"$(dgf).find(..\" in datagridfield.js line 138 so it binds to right element only.\n [tareqalam]\n\n- Only abort moveRow if the row is really not found and not if the row idx just happens to be 0.\n [gaudenz]\n\n- Also update hidden data rows when reindexing in row mode. This fix was previously somehow only done for block mode.\n [gaudenz]\n\n- Relax requirements for markup, don't assume inputs are direct children of table cells. This makes using custom\n templates much easier.\n [gaudenz]\n\n- Fix validate function signature for IValidator API. The API requires a \"force\" argument.\n [gaudenz]\n\n- Register the SubformAdapter for IPloneForm layer to avoid that the Adapter from plone.app.z3cform\n takes precedence.\n [gaudenz]\n\n\n0.14 (2013-05-24)\n-----------------\n\n- Align travis setup to other packages.\n [saily]\n\n- Add new V1 ``bootstrap.py``.\n [saily]\n\n- Added CSS classes to tbody rows (``row-(1...n)``) and thead columns\n (``cell-(1...m)``) to allow more styling in edit forms.\n [saily]\n\n- Fixed wrong template in display mode when set editing to block edit mode [miohtama]\n\n- Added CSS classes (widget.klass attribute) for DataGridField, to separate it from other MultiWidgets [miohtama]\n\n\n0.13 (2013-04-09)\n-----------------\n\n- Add travis-ci configs [jaroel]\n\n- Convert tests to plone.app.testing [jaroel]\n\n- Fix to expect ``zope.schema.interfaces.ValidationError`` to work better\n with *TooLong* and *TooShort* exceptions. [datakurre]\n\n- Fix IE7 failing on `<label>` for manipulation [miohtama]\n\n- Deal with situations where there is zero rows on DGF and no auto-append row available [miohtama]\n\n- Correctly bind DGF events on DOM content loaded, not when Javascript is parsed [miohtama]\n\n- Don't display movement handles if the row cannot be moved [miohtama]\n\n- Changed move up and down handlers to stay in fixed positions to make cells stay in the same width regardless of moving [miohtama]\n\n- Fixed checkbox saving, was broken by nested DGF support [miohtama]\n\n- Added block edit mode [miohtama]\n\n- \"use strict;\" and ECMAScript 5 compatible Javascript clean-up [miohtama]\n\n- Added *afterrowmoved* JS event [miohtama]\n\n\n0.12 (2012-10-30)\n--------------------\n\n- Updated empty row selection. [jstegle]\n\n- Nested DataGridField support (yo dawg...) [miohtama]\n\n- Support plone.autoform and grok'ed row schemas [miohtama]\n\n- Added ``DataGridField.extra`` parameter, so you can pass out\n application specific data to Javascript [miohtama]\n\n\n0.11 (2012-05-16)\n-----------------\n\n- be able to use with plone.app.registry\n [vangheem]\n\n\n0.10 (2012-02-12)\n-----------------\n\n- Fix bug with moving the last row up.\n [m-martinez]\n\n\n0.9 (2011-10-27)\n----------------\n\n- Clone events when adding new row - fixes bug where browse button of\n plone.formwidget.contenttree did nothing for new rows\n [anthonygerrard]\n\n- Reindex more indexed attributes of cloned row\n [anthonygerrard]\n\n\n0.8 (2011-09-24)\n----------------\n\n- Avoid using the \"row\" CSS class.\n [davisagli]\n\n- Fixes to work with jQuery 1.3.x (use .remove() instead of .detach(), fetch data\n attributes a different way, and avoid live binding the change event).\n [davisagli]\n\n- Don't error out when getting a ``FormatterValidationError``, pass\n it on to z3c.form instead.\n [claytron]\n\n- Give manipulator images a relative src rather than absolute. This\n previously meant the widget didn't work on sites without Plone/Zope at the\n root of the domain.\n [davidjb]\n\n- During auto-insert, add our new row into the document first, before reindexing\n it and changing its elements' IDs. This allows Javascript that depends on\n these IDs (such as plone.formwidget.autocomplete) to pick up the correct\n fields.\n [davidjb]\n\n- Tidying up and reducing complexity of auto-insert functionality\n [davidjb]\n\n- Removing unnecessary auto-insert bind and unbind as this is already covered\n by jQuery's `live()` function against the `auto-append` class. Adding/removing\n this class against rows automatically does this.\n [davidjb]\n\n- Resolved issue with auto-insert functionality not working by removing\n table-specific check in Javascript.\n [davidjb]\n\n\n0.7 (2011-07-01)\n----------------\n\n- Changed markup/javascript to prevent duplicate HTML id attributes. Changed\n Javascript to allow for datagrid page templates that don't use tables.\n [dextermilo]\n\n- Improve spacing in CSS.\n [davisagli]\n\n- Revert my fix to ensure that blank rows are added, because it duplicated\n a fix in z3c.form resulting in extra rows.\n [davisagli]\n\n\n0.6 (2011-05-17)\n----------------\n\n- Search for datagridInitialise and datagridUpdateWidgets on the\n parent form, also when in a fieldset.\n [maurits]\n\n- Register templates on plone.app.z3cform.interfaces.IPloneFormLayer to\n take precedence over that packages list widget templates.\n [elro]\n\n- Make sure that updateWidgets is called to add blank rows even if the\n widget has no value.\n [davisagli]\n\n- When extracting a row value fails due to a validation error, convert\n widget values to field values so the value can be successfully applied\n to the grid widget.\n [davisagli]\n\n- Register a plone.supermodel handler for the DictRow so it can be used\n in supermodel models.\n [davisagli]\n\n- Depend on collective.z3cform.datagridfield_demo as a test extra;\n use the browser view from this package in the tests.\n [maurits]\n\n- _validate still used when import/exporting, fix up code so it works\n [lentinj]\n\n- Add a DictRow serializer for transmogrify.dexterity\n [lentinj]\n\n- Only use width:100% on input cells that are the only element in the cell\n [lentinj]\n\n- Reorder row indices backwards when adding rows. This means that adjacent\n rows don't share the same index temporarily, for example:-\n - Row 1 and 2 contain input:radio based widgets\n - Row 0 added, row renumbering starts\n - Row 1 widgets renamed 2\n - Both sets of input:radio share the same name, one deselected\n - Row 2 widgets renamed 3\n - . . .\n [lentinj]\n\n- Use jQuery to clone rows, and clone the jQuery events on the rows.\n [lentinj]\n\n- Implemented reorder functionality\n\n\n0.5 (2011-02-08)\n----------------\n\n- Put in the DictRow class (tks Martin Aspeli)\n\n- Moved the demo code out to a separate package collective.z3cform.datagridfield_demo\n (tks Laurence Rowe).\n\n- Removed superfluous lines from setup.py (tks Laurence Rowe).\n\n- Removed unnecessary dependency on dexterity (tks Laurence Rowe).\n\n- Removed unnecessary dependency on grok (tks Laurence Rowe).\n\n\n0.4 (2011-02-06)\n----------------\n\n- Renamed the demo pages. The starting point is now @@demo-collective.z3cform.datagrid .\n\n- The widget can now be configured via the updateWidgets method. It\n is no longer necessary to create a custom factory.\n\n- The columns can now be omitted.\n\n- Provide a set of demo views for Object access.\n\n\n0.3 (2011-02-04)\n----------------\n\n- The auto-append functionality did not bind correctly for popup forms.\n I switched to using jQuery.live() instead of binding at document load time.\n\n- Added a menu to the demo pages\n\n- Added a display only form option.\n\n- Fixed the restructured text of the main README.txt so that it will show\n more friendly in PyPI.\n",
"bugtrack_url": null,
"license": "GPLv2",
"summary": "Fields with repeatable data grid (table-like) for z3.cform",
"version": "3.0.3",
"project_urls": {
"Homepage": "https://github.com/collective/collective.z3cform.datagridfield"
},
"split_keywords": [
"plone",
"z3cform",
"table",
"data",
"grid"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "61b8362a2394c861c0fa66bd471b68b7a4644000c843a17314e992cc74ffdea5",
"md5": "ba4cebbd573d54f19cec5de7dae10fdf",
"sha256": "645c2323e638cf275776c5ef66171cc24f785e2950ee2469e090c8c8489499d3"
},
"downloads": -1,
"filename": "collective.z3cform.datagridfield-3.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ba4cebbd573d54f19cec5de7dae10fdf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 391106,
"upload_time": "2024-11-05T13:59:53",
"upload_time_iso_8601": "2024-11-05T13:59:53.652159Z",
"url": "https://files.pythonhosted.org/packages/61/b8/362a2394c861c0fa66bd471b68b7a4644000c843a17314e992cc74ffdea5/collective.z3cform.datagridfield-3.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2b69fb5f0e9828b25fe946b3f65c83e4a8e7618de17252c377b71361ceb5d4a3",
"md5": "40ba5350e639f83d1cd158a05749fa8b",
"sha256": "8cd37430680909433fd54c42e2349d5d011877591431af1cb282b7373d27b678"
},
"downloads": -1,
"filename": "collective_z3cform_datagridfield-3.0.3.tar.gz",
"has_sig": false,
"md5_digest": "40ba5350e639f83d1cd158a05749fa8b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 559398,
"upload_time": "2024-11-05T13:59:57",
"upload_time_iso_8601": "2024-11-05T13:59:57.818431Z",
"url": "https://files.pythonhosted.org/packages/2b/69/fb5f0e9828b25fe946b3f65c83e4a8e7618de17252c377b71361ceb5d4a3/collective_z3cform_datagridfield-3.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-05 13:59:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "collective",
"github_project": "collective.z3cform.datagridfield",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "collective.z3cform.datagridfield"
}