2

Is it possible to add ClickListener to a TextField component? I render a read-only TextField in the Grid column component. The column has expandable details. But when I click on TextField there - nothing happens. With help of ClickListener I plan to expand Grid details programmatically.

alexanoid
  • 24,051
  • 54
  • 210
  • 410
  • 1
    You can also use Native Button Renderer (unless you really need a clickable read-only text field). https://vaadin.com/docs/latest/components/grid/flow/#using-renderers-in-columns – Roman Kovařík Aug 22 '22 at 12:27

1 Answers1

4

Sure you can add any JavaScript listener with this method:

textField.getElement().addEventListener("click", event -> Notification.show("click"));
Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82