alejandro-du / crudui

Automatically generate CRUD-like Vaadin views for any Java Bean
https://vaadin.com/directory#!addon/crud-ui-add-on
Apache License 2.0
85 stars 54 forks source link

Add support for colspan in DefaultCrudFormFactory #94

Closed alejandro-du closed 3 years ago

alejandro-du commented 3 years ago

From https://vaadin.com/forum/thread/14437640/crud-ui-add-on?page=5:

Alejandro, your CRUD-UI is areal life-safer.... It makes things so easy....

But there is just one thing I'm missing or I'm just too blind to see it....

I'd like to have some fields to span multiple coloumns, so I can have a "two column layout" for for my "short" fields and under those "short properties" I'd like to have some properties that span th two columns because they usually contain long text...

If this is possible I don't get how...

Thanks for any hint, Michael

alejandro-du commented 3 years ago

Version 4.6.0 includes the new functionality. Usage example:

DefaultCrudFormFactory<User> formFactory = new DefaultCrudFormFactory<User>(User.class) {
    @Override
    protected void configureForm(FormLayout formLayout, List<HasValueAndElement> fields) {
        Component nameField = (Component) fields.get(0);
        formLayout.setColspan(nameField, 2);
    }
};
realulim commented 1 year ago

Works great for me, thank you!

realulim commented 1 year ago

On second thoughts, the configureForm method is called for all operations, be they findAll, add or delete. But typically in the delete form you won't have the same fields as in the add form, so accessing the fields by index will yield different results. Also, you might want to have colspan=2 in the add form, but not in the delete form, whereas in the findAll you would like to skip everything, because you're in a grid and not in a form.