E-Mail Adress and Phonenumber in Vaadin Grid

Hi everbody,
I’m looking for a solution to get clickable e-mail adress phonenumber in vaadin grid but didn’t find any solution here in the forum.

I need to get somthing like this E-Mail with Blindcopy into the grid.
Should this be done with the HtmlRenderer? If yes, how do I get this to work?

I’m using Vaadin 8.3.3

Hope anyone can help me.
Best regards
Peter

Hi Peter

Something like this works

 Grid<Person> grid = new Grid<>();
        grid.addColumn(Person::getEmail, email -> "<a href='mailto:" + email + "bcc=max.m@example.org'>E-Mail with Blindcopy</a>" , new HtmlRenderer());
        Collection<Person> persons = Arrays.asList(new Person(1l, "Paul", "paul@imba.com"));
        grid.setItems(persons);
        setContent(grid);

it creates a column with links.

sory for hardcoding it, i hope you will make a nice method for the email html link :slight_smile:

Hi Vilius,
thank you very much for your help. Exactly what I’m looking for.
Kind regards
Peter

You are welcome, glad i could help.

Hi again,
I have an aditional question to this topic. Is it also possible to add this functionality to an existing column instead of adding a new one?

What I mean is something like this:

list.getColumn("email").setRenderer(Person::getEmail,email -> "<a href='mailto:" + email + "'>" + email + "</a>",new HtmlRenderer());

Thanks for your help.

Kind Regards
Peter

sure. Exactly how you wrote :slight_smile: !

basicaly you can take the Grid Column

Grid.Column<Person, ?> emailColumn = grid.getColumn(EMAIL_COLUMN);


and Change the renderer on click


emailColumn.setRenderer( email -> "<a href='mailto:" + email + "bcc=max.m@example.org'>E-Mail with Blindcopy</a>" , new HtmlRenderer());
 
 OR 
 
 emailColumn.setRenderer(new TextRenderer());

demo on heroku (sleep modus, takes time to start)
[https://changerenderer.herokuapp.com/]
(https://changerenderer.herokuapp.com/)

code
[https://github.com/Vilkaz/email-in-grid]
(https://github.com/Vilkaz/email-in-grid)

Thank you very much again. Works like a charm :slight_smile:

You are welcome ! gl !