Datagridfield in mosaic

Has anyone managed to use DataGridField in mosaic.

If not, is there any other way to to this, using a Tuple, maybe ??

(to construct something like this: )

My recurring pattern for these is to simply use textfield and write a custom JS widget for taking input and serialising it into lines is JSON. (Although, note that plone modal pattern has many issues here: it breaks widgets with buttons and prevents React-like frameworks from functioning by default by capturing their events.)

Interesting...for me, it's rendering but not saving.

Check that datagridxield is installed and that it is latest version

I ended up using schema.Object with schema.List to accomplish what I wanted to do with datagridfield. See for example.

1 Like

yeah, i think we should build a more lightweight widget for that.
Which uses JSON or DictField to store the data.
DataGridField and also the schema.Object way has some disadvantages.
If you just need some nested data in a flexible structure, JSON + a lightweight JS widget is what you want.
But it would be good to have something like this, which people could use instead of using DataGridField or the Object/List, which is way to complex at the end.

I think your approach is overly complex; we use a single RichText field and some JavaScript to do things like that, it's cleaner and way easier.

I'm aware of this approach, however, the aim was to get sub forms to work in moasic. After all, there might be subforms with multiple fields of different data types.
This why I chose to use datagridfield or schema object/list. I don't think it's overly complex, because all that is added for both approaches is a factory adapter class. Nothing else was added to create the mosaic tile nor the subform.

Yes, I agree. Datagridfield is a better approach. It stores the data as dictionary. The reason why I didn't use it was because the css was broken in moasic, at least for me.

Yes, it sounds funny that I didn't use it because of css considering that I did schema object/list approach. The thing is, I still had to define the factory class for the subform. Therefore, the code for schema objext/list is like a subset of Datagridfield

I feel like @tareqalam worked on something similar in the 2017 Plone Conf sprints.

I don't think so, angular is to big for this kind of stuff.
All what we need is a bit of javascript which works tablelike as jQueryDataTables does.
On the backend we can use TextField or something with Dict/JSON-Support.
Which could be useful for validating the json on the backend.
But could work without too.
This would be usefull for most of the usecases where you otherwise would have to use DataGridField & co.
But it's way simpler and proably easier to use, as you can find good javascript UI-libs for that.
All it would need is a columns definition on the widget.

@b4oshany yes you are right it works, but using objects and schema related things, can bite you on many places in the future. Because it always needs the Python classes right in place. And when i played last with object fields, it was painful. Some stuff was only working on editforms but not on addforms and so on.

And if you only want some table like data, why should one use all the complex stuff.
Also DataGridField does not work completly TTW, which could be enother reason to avoid it.

don't get me wrong, there are probably good usecases for DataGridField & co, but it's just not all the needed.

If we could have a 'multi-image' field, it would be awesome.

So, you add 'title', 'description', image (and maybe image-caption, and the viewlet is a slideshow.

(putting the images in the container is not as good, as you might need to put other items there as well

can't you use the content-listing tile for that with a template which is listing the images? I mean images have all that fields already.

Plone Foundation Code of Conduct