Help with Grid Sorter

I create a custom grid:

public class GridProtocolo extends Grid<Protocolo>{
  public GridProtocolo() {
     addStyleName("gridProtocolo");
     setSizeFull();

     setStyleGenerator(GridProtocolo::getRowStyle);

   Column<Protocolo, String> iconColumn = addColumn( order -> twoRowCellIcon(Utils.getIconCorretoFromTipoProtocolo(order.getTipo()).getHtml(), "3!","Protocolo nº:",order.getNumero(), order.getTipo()), new HtmlRenderer()).setCaption("Nº PROT.").setWidth(110);
  
Column<Protocolo, String> naturezaColumn = addColumn( order -> twoRowCellNatureza("Natureza:",order.getNatureza().getNome(),"Parte:",order.getParte()), new HtmlRenderer()).setCaption("NATUREZA");

Column<Protocolo, String> vencimentoColumn = addColumn( order -> twoRowCellNatureza("Data Venc.:", Utils.dateFormat.format(order.getDataVencimento()),"CPF/CNPJ:",order.getParteDocumento()), new HtmlRenderer()).setCaption("DATA VENC.");

Column<Protocolo, String> statusColumn = addColumn( order -> twoRowCellStatus("Status:",order.getStatus().getStatus().getNome(),"Saldo:",Utils.convertFromMoney(order.getSaldo().getValor())), new HtmlRenderer()).setCaption("STATUS");
  }

private static String twoRowCellIcon(String icon, String alertas, String captionProtocolo, Long protocolo, TipoProtocolo tipo) { return "<div class=\"icon\">" + icon + "<div class=\"caption\">" + captionProtocolo + "</div><div class='contentProtocolo "+TipoProtocolo.recuperaTipoProtocolo(tipo).toLowerCase()+"'>" +TipoProtocolo.recuperaTipoProtocolo(tipo) + " - "+ protocolo + "</div>"; }

private static String twoRowCellNatureza(String captionNatureza, String natureza, String captionParte, String parte) { return "<div class=\"caption\">" + captionNatureza + "</div><div class=\"content\">" + natureza + "</div>" + "<div class=\"caption\">" + captionParte + "</div><div class=\"content2\">" + parte + "</div>"; }

private static String twoRowCellStatus(String captionStatus, String status, String captionSaldo, String saldo) { StringBuffer retorno = new StringBuffer(); retorno.append("<div class=\"caption\">" + captionStatus); if(status.equalsIgnoreCase("REGISTRADO")){ retorno.append("</div><div class=\"content green\">" + status); }else if(status.equalsIgnoreCase("DEVOLVIDO")){ retorno.append("</div><div class=\"content red\">" + status); }else{ retorno.append("</div><div class=\"content\">" + status); } retorno.append("</div>" + "<div class=\"caption\">" + captionSaldo); retorno.append("</div><div class=\"content2\">" + saldo); retorno.append("</div>"); return retorno.toString(); }

}

Then I use in my view:

public class BuscarProtocolosImpl extends BuscarProtocolos implements View{
  @Autowired ProtocoloService protocoloService;
  private ListDataProvider<Protocolo> dataProvider;
ConfigurableFilterDataProvider<Protocolo, Void, ProtocoloFiltro> filteredProvider;

public BuscarProtocolosImpl() {
   DataProvider<Protocolo, ProtocoloFiltro> myProvider = DataProvider.fromFilteringCallbacks(query -> { return protocoloService.findAll(query.getOffset(),query.getLimit(), query.getFilter()).stream();}, query -> { return protocoloService.countFindAll(query.getFilter());});

filteredProvider = myProvider.withConfigurableFilter();
gridProtocolo.setDataProvider(filteredProvider);
}

}

[code]
So How can I configure to when my user click in my Grid Header the grid sorter? tks
[/code]

Are you asking method to set specific Grid sortable or not, it is

Grid.getColumn(…).setSortable(true/false)

For sorting you need to use e.g. ListDataProvider. If you need custom sorting, you need to use setSortComparator to set your own sorting method. It can be lambda expression.