The correct way to render a datagridfield in a view

Hi everyone,

I have a problem rendering a datagridfield in my view. With my limited knowledge, I cannot find a way to render it directly in a view as readonly, although I can use it smoothly in the edit form. I am using the latest version of it 1.5.3.

I appreciate so much your help as it is taking a 2 days now without finding a correct way to render it.

I am using plone 1.5.6
I am referring to this page Fields and widgets — Plone Documentation v5.2
but it does not help.

regards

Osama

Usually you have field definition like

    form.widget(contact_keywords_en=DataGridFieldFactory)
    contact_keywords_en = schema.List(
        title=_("Contact keywords EN"),
        description=_(
            "Keywords for contact portlets in EN. One (short) item per line!"
        ),
        required=False,
        value_type=DictRow(title=_(u"Keywords"), schema=IKeywordRow),
        default=[],
    )

In our case, we have one col per per row:

class IKeywordRow(model.Schema):

    keyword = schema.TextLine(title=_(u"Keyword"), required=True)

So context.contact_keywords_en is a list of Python dicts where each dict has one key-value pair keyword.

View:

<ul>
  <li tal:repeat="d context/contact_keywords_en">
    <span tal:content="d/keyword"/>
  </li>
</ul>

This helped a lot. It is simpler than I thought. it is working perfect.
Thanks so much

1 Like