List / Repeater component for Vaadin
Asked Answered
H

1

7

In my previous project, I've used BeanItemContainer and a Table with GeneratedColumns to simply display a custom component that displays a search result, like google. Title, date, content in a vertical fashion. As horrible as it was (table) it worked.

Now I want to utilize Grid component for a new project, with the same objective. The column will be generated and contain a custom component.

Will this work with Grid? is there something better, like a list or repeater component available? Any example of a single column with custom component?

It seems like Vaadin frowns on anything other than simple data or Button renderers.

Update

It looks like adding components don't work out of the box with Grid 7.5+

Also, Grid cells like to be only be fixed hight

ComponentRederer Add-on support cell components, however fix height is still an issue.

Sample code:

 public class Result {
      String title;
      Date date;
      URL url;
      String description;
      List<String> tags;

      public Result (){}

 }

BeanItemContainer<Result> resultContainer = fetchResults(searchTerm);

I also use a Lazy Container too, beanitem used for simplicity.

I then have a RecordResultComponent that constructs the layout of a single record result in the follow layout:

 Title(link with Url)
 Date
 Description
 tag1 tag2 tag3 ...
Hydrology answered 1/9, 2016 at 16:53 Comment(7)
Why use table/grid and not simply iterate through your item list, create an instance of your custom component for each item and add them in a vertical layout (or maybe a grid layout)?Caracara
I have a large amount of data and wanted to utilize the container-backed components.Hydrology
its strange that table can render component and grid not out of the box. i guess you want to display also a lot of other columns and not only the component column. but if you dont need any table functionality like sorting, you could use a simple verticallayout.Comintern
You could also use FieldGroup binding to some extent in order to achieve a similar effect, however it is difficult to imagine what exactly you're trying to do without seeing some code. Any chance you could share a sscce?Caracara
a lazy loading mechanism when the user scrolls (like table) would be greatAngevin
@agassner, I've used table in the past, and that is what I will most likely have to use again. Just hoped there was a better alternative.Hydrology
I might be misunderstanding the situation but the basic vaadin tutorial features displaying content like this in a grid, hope this helps.Evasion
K
0

You can use a Grid alongwith a GeneratedPropertyContainer.

Then, you can use a HtmlRenderer on the custom column.

I hope it helps. :-)

Kymric answered 12/1, 2017 at 4:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.