-
Notifications
You must be signed in to change notification settings - Fork 173
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
Date input search with problem #59
Comments
To handle a date, you'll have to provide your own specification (since the library cannot know whether a field contains a date or not): public DataTablesOutput<User> getUsers(@Valid DataTablesInput input) {
ColumnParameter parameter0 = input.getColumns().get(0);
LocalDate date = LocalDate.parse(parameter0.getSearch().getValue());
Specification additionalSpecification = getSpecificationForDate(date);
parameter0.getSearch().setValue("");
return userRepository.findAll(input, additionalSpecification);
} |
I figure out how to make a date search, I'm using Postgres and the date type is stored like '2017-01-01 00:00:00', so what I made was to parse date to a date string that have the same format, but in JavaScript. Finally my JS function ended up like this: And Worked 👍 |
Sorry to bring the old thread back. I am having a similar problem. Setting the date between returns empty table. Here is the code
|
Hi @darrachequesne , where is
Thanks |
I think the class Column works. Hi @darrachequesne, I have this same problem. A column in BD that is a Date that cant be search by the value of the input. Im trying to work on the code for the Specification to solve this, but I cant. Can you or anybody else write or explain the code inside the method getSpecificationForDate(date)? Thanks. |
Hi,
firstly I congrates you for a great job that you make, I search something like this.
But when I search on the function column(0).search(valueDate).draw() the Query search parameter is a varchar type on the date attribute. This result in nothing.
In debug log of hibernate the query is setting like this:
from movimento movimento0_ where 1=1 and (lower(cast(movimento0_.data as varchar(255))) like ? escape ?) order by movimento0_.data asc limit ?
the parameter are:
binding parameter [1] as [VARCHAR] - [%02/07/2017%]
binding parameter [2] as [CHAR] - []
Do you have searched a date type already?
The text was updated successfully, but these errors were encountered: