Editing tabular data and using datatables for Plone 5

In a non-Python solution of mine, end users can enter their own data—like a staff directory, roster, or incidents—and have that data presented in a table that can be searched and sorted, with links to the details for each record entered. It's all server side, though, and I want to modernize it. Examples: http://www.norcalreferees.com/incidents/ and http://www.ibew234.org/list_of_contractors/

Where would I start to figure out how to do this in Plone, where end users enter data, but using something like datatables.js for the front end?

I made:

(but it has never been used in production, so it might need a little love.)

... anyway: there might be 'something there' that is usable.

If you're talking about rosters, check collective.roster or FacultyStaffDirectory (yes, it's Archetypes, but it works with P5), or try what I mentioned in Open Source Reporting tool

We use collective.js.datatables in a number of places. Works well. EDIT: oops I have no idea about how/whether it works on Plone 5 (yet). We're on P4 still... Checking the PRs and issues, you can see that some effort has been made to upgrade it to work on P5, at least.

Another add'on for Plone 4 that has a soft dependency on Datatables is collective.tablepage , developped by RedTurtle . https://pypi.python.org/pypi/collective.tablepage#other-products

It's a fairly complete solution for flexible not so huge tables. But also Plone 4 and Archetypes, except for the resource management porting this to Plone 5 shouldn't be too complicated, everything is contained in one content type afaik.

1 Like

There's a z3c.form datagrid fieldtype: https://github.com/collective/collective.z3cform.datagridfield

I'd guess sorting/filtering could be done in your view.

Implementing is straightforward:

    <field name="dibac_table" type="zope.schema.List">
      <title>Dibac Phrasen Tabelle</title>
      <value_type type="collective.z3cform.datagridfield.DictRow">
      <form:widget type="collective.z3cform.datagridfield.DataGridFieldFactory"/>

and an interface:

class IDibacTableRowSchema(Interface):
    dibac_field_type = schema.Choice(title=u"Feldtyp", vocabulary="my_theme.DibacFields", required=True)
    dibac_field_verweis = schema.TextLine(title=u"Phrase Verweis", required=True)
    dibac_field_extra = schema.TextLine(title=u"Zusatz Info", required=False)

results in

you could add indexing behavior to make individual grid elements searchable.

1 Like

@mtrebron That's interesting, thank you for the example. I tried a while ago to get this working in a python schema for a DX contenttype, but couldn't get it working.

Now I spotted I probably got the value_type wrong, or maybe something else. I'll try it again. xml to Interface should be straightforward. The example in collective.z3cform.datagriedfield's README is only for a form.