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 ...
steve
  • 1,786
  • 1
  • 15
  • 29
  • 2
    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](https://vaadin.com/docs/-/part/framework/layout/layout-orderedlayout.html) (or maybe a [grid layout](https://vaadin.com/docs/-/part/framework/layout/layout-gridlayout.html))? – Morfic Sep 01 '16 at 17:45
  • I have a large amount of data and wanted to utilize the container-backed components. – steve Sep 01 '16 at 18:44
  • 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. – d2k2 Sep 02 '16 at 08:26
  • You could also use [`FieldGroup` binding](https://vaadin.com/docs/-/part/framework/datamodel/datamodel-itembinding.html) 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](http://sscce.org)? – Morfic Sep 02 '16 at 08:28
  • a lazy loading mechanism when the user scrolls (like table) would be great – agassner Sep 02 '16 at 10:32
  • @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. – steve Sep 02 '16 at 16:10
  • I might be misunderstanding the situation but the [basic vaadin tutorial](https://vaadin.com/docs/-/part/framework/tutorial.html) features displaying content like this in a grid, hope this helps. – Adalcar Sep 15 '16 at 16:25

1 Answers1

0

You can use a Grid alongwith a GeneratedPropertyContainer.

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

I hope it helps. :-)

Vikrant Thakur
  • 715
  • 5
  • 7