Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order can be null #156

Closed
smsotirov opened this issue Mar 1, 2024 · 4 comments
Closed

Order can be null #156

smsotirov opened this issue Mar 1, 2024 · 4 comments
Labels
Milestone

Comments

@smsotirov
Copy link

On the latest datatables implementation, when you click on the order headers, there is 3 options. Ascending, descending and none. The spring-data-jpa-datatables plugin works on the first two, but fails on 3rd becasue of the validation in DataTablesInput for the field "order" which is @NotEmpty

To reproduse, just click more than twice on the order header on any column. You will see that the arrows toggles to ASC, DESC and the third option is basically none. I this third case, the request looks like this:

draw: 3
columns[0].data: name
columns[0].name: 
columns[0].searchable: true
columns[0].orderable: true
columns[0].search.value: 
columns[0].search.regex: false
columns[1].data: roleprefix
columns[1].name: 
columns[1].searchable: true
columns[1].orderable: true
columns[1].search.value: 
columns[1].search.regex: false
start: 0
length: 10
search.value: 
search.regex: false

No "order" in the request. This causes an error.

@smsotirov
Copy link
Author

smsotirov commented Mar 1, 2024

I forgot to add what is in the console:

[Field error in object 'dataTablesInput' on field 'order': rejected value [[]]; codes 
[NotEmpty.dataTablesInput.order,NotEmpty.order,NotEmpty.java.util.List,NotEmpty];

@darrachequesne
Copy link
Owner

Hi! I could indeed reproduce the issue with DataTables v2.0.1.

Columns can now have three ordering states - asc, desc or data index order (specified by an empty string). The columns.orderSequence option has been updated to make use of this, so the third ordering on a column will now take it back to the index order, rather than returning to the first direction.

Reference: https://cdn.datatables.net/2.0.0/

I think removing the @NotEmpty constraint should be enough, what do you think?

@smsotirov
Copy link
Author

By the first glance over the code, I also think it will be enough. I think the addOrder() method will handle it.

darrachequesne added a commit that referenced this issue Mar 3, 2024
The "order" attribute can be empty in two cases:

- when setting "ordering: false"

Reference: https://datatables.net/reference/option/ordering
Related: #107

- with DataTabbles 2.0

> Columns can now have three ordering states - asc, desc or data index order (specified by an empty string). The columns.orderSequence option has been updated to make use of this, so the third ordering on a column will now take it back to the index order, rather than returning to the first direction.

Reference: https://cdn.datatables.net/2.0.0/
Related: #156
@darrachequesne
Copy link
Owner

This should be fixed by a214d5b, included in 6.0.2.

@darrachequesne darrachequesne added this to the 6.0.2 milestone Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants