How to add a Button to Grid Caption in Vaadin 8?

Actually I had add a button to Grid Caption with grid.setCaption("<div><button >click me</button></div>");grid.setCaptionAsHtml(true);,but I don’t know how to handle the button event?Any advice?

The approach you have tried, does not work. Instead You should do something like

Do something like this (pseudocode)

grid.addColumn(..).setId("columnId")

Button button = new Button("click me");
button.addClickListener(event -> { 
   ...
});
...
grid.getHeaderRow(0).getCell("columnId").setComponent(button)

Thank you! It has been useful for me !!!