2
How do I sort a datatable by a text. For example my system is a service order system, I need the "Open" orders to come first. Follow the code of the datatable below. I tried to use sortby but it did not give me result.
This is my list:
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 through 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 situation 'In Open' has to come first.
maybe sort sql would work, but I don’t know how to do sql if anyone knows. I tried so but it didn’t 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";
Welcome to Stack Overflow! You used the comments area to add clarifications or ask a question. Instead, it is better to [Dit] your question and include that content right there. For that, there is a [Dit] link below the question. Thus, the content is all gathered in one place, and those who arrive here need not be looking for information in various comments to understand the problem.
– Jorge B.
I posted the code right above.
– Leandro Santos