darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
448 stars 172 forks source link

AddOrder doesnt seem to work #149

Closed CharlesPMG closed 1 year ago

CharlesPMG commented 1 year ago

I have this class that just return the DataTableOutput, I want to add order desc on the Id column image In my view, It doesnt order by this id.

darrachequesne commented 1 year ago

Hi! I guess that's because there is already an order (sent by the frontend). Can you check in the input object?

You can remove any existing order with:

@RequestMapping(value = "/employees", method = RequestMethod.GET)
public DataTablesOutput<Employee> list(@Valid DataTablesInput input) {
    input.getOrder().clear();
    input.addOrder("age", true);
    return employeeRepository.findAll(input);
}

Though in that case, any specific ordering requested by the frontend will be ignored.

darrachequesne commented 1 year ago

Closed due to inactivity, please reopen if needed.