Datagridfield thru the web

Hi everybody,

we are investigating about possibility to manage some datagridfields thru the dexterity content types configuration panel, so to be able to add a datagridfield field to a custom dexterity type.

For now (I think) it is not possible to add a field of type "datagridfield" when adding a new custom dexterity type.

However, I see that is it possible to define a datagridfield using supermodel XML but there, the value_type is an existing schema defined on the FS.

Has anybody already think or work on this?

We thought about different ways like using a custom dexterity type as value_type for the datagridfield field : for example we would add a custom DX to define the datagridfield model then use this custom DX as value_type for the datagridfield field added TTW.

I think that would be an awesome functionality and would let us propose an alternative to our users to an excel/google sheet.

Thank you for feedback,

Gauthier

This is not possible for now as you noticed.

I am not very familar with the supermodel implementation but a supermodel maps to a schema and the schema editor of Plone should in some way be able to define a schema.

So a rough blueprint would be to define a particular datagridfield schema through the schema editor and reference it somehow from your content type with the datagridfield...

@zopyx thank you for feedback. Indeed I think it could be doable some dx custom types just created to be used as datagridfield value_type.

We will maybe try to implement this but actually we wanted to know if it was a good way to go or if anobody had another good way to implement it or advices.

Thank you!

Gauthier

I am quite sure possible to add this TTW, but just for some value types.

The field type would be (for example) list and you need to set value_type and widget.

That said: the easy way is to make behaviors that you can reuse… then you just add the behavior TTW.

@bjorn_again

the problem with behaviors is that it is "hardcoded", we need this to replace some "xls" sheets and users come with their own needs and need that quickly...

Thank you for feedback,

Gauthier

As mention in other posts later, I set in interfaces.py

class IMailColumns(Interface):
    """ Datagrid for contact_info mail
    """

    namel = schema.TextLine(
        title=_(u'Name'),
        required=False,
    )

    email = schema.TextLine(
        title=_(u'E-mail'),
        required=False,
    )

And then in the XML TTW, something like

    <field name="lokalt_russestyre" type="zope.schema.List">
      <title>Lokalt russestyre</title>
      <value_type type="collective.z3cform.datagridfield.DictRow">
          <schema>my.addon.interfaces.IMailColumns</schema>
      </value_type>
      <form:widget type="collective.z3cform.datagridfield.DataGridFieldFactory"/>
    </field>

But I don't think if it is possible to set any 'options' in XML, like

   <form:widget type="collective.z3cform.datagridfield.DataGridFieldFactory"
allow_reorder="True"/>

… that would be nice :slight_smile: