How do I sort a datatable by a text. For example my system is a system of order of services, I need the orders "Open" to come first. Follow the datatable code below. I tried sortby but it did not work.
This is my listAll:
public List<Ordens> listarTodos() {
String sql = "select o from Ordens as o inner join o.usuario as u where u.id "
+ " = "+UserStatic.getUsuario().getId();
I need to sort by this column:
<p:column filterBy="#{b.situacao}" headerText="Situação Técnico" sortBy="#{b.situacao}" style="width: 98px;"> <h:outputText value="#{b.situacao}" style=" color: red"/> </p:column>
The 'Open' situation has to come first.
Maybe ordering in sql would work, but I do not know how to do it in sql, if anyone knows. I tried this way more did not work
public List<Ordens> listarTodos() {
String sql = "select o from Ordens as o inner join o.usuario as u where u.id"
+ " = "+UserStatic.getUsuario().getId()
+"order by o.situacao DESC";