Peter631
(Peter Korbl)
May 7, 2018, 5:25am
1
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
Vilius2
(Vilius Kukanauskas)
May 7, 2018, 6:55am
2
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
Peter631
(Peter Korbl)
May 7, 2018, 6:58am
3
Hi Vilius,
thank you very much for your help. Exactly what I’m looking for.
Kind regards
Peter
Vilius2
(Vilius Kukanauskas)
May 7, 2018, 7:11am
4
You are welcome, glad i could help.
Peter631
(Peter Korbl)
May 10, 2018, 5:27am
5
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
Vilius2
(Vilius Kukanauskas)
May 10, 2018, 7:25am
6
sure. Exactly how you wrote !
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 )
Peter631
(Peter Korbl)
May 10, 2018, 4:08pm
7
Thank you very much again. Works like a charm