SearchBuilder: pre-define values for moment-datetimepicker
SearchBuilder: pre-define values for moment-datetimepicker

Hi all,
today I struggled with the following problem:
In my datatable, I use moment to format columns of TIMESTAMP values to be in a specific format. I also use SearchBuilder, which works perfectly fine with it.
However, whenever I try to use SearchBuilder to filter a specific datetime and I click on the moment datetimepicker, it takes the current date AND time.
Is there a way to manipulate it to specific values?
Example:
That's how it is at the moment:
I would like to have the ability to, whenever I click in the first field, to set the time to 00:00:00 and the second field to time 23:59:59 in order to get all entries of the current date without the need to adjust the time values specifically.
Is there a way to achieve this?
Thanks in advance and have a nice start into the week,
Daniel
This question has accepted answers - jump to:
Answers
Hi @schwaluck ,
This should be possible. You'll want to create a custom init function I suspect, take a look at this example for a template.
SearchBuilder uses this code to initialise the 2 input elements for selecting dates. The best place to start would be to take that and edit it to suit your needs.
You should be able to just set the value of the input elements to whatever you want the default to be. Take a look at this example and create a between on the created column.
Hope this helps,
Sandy
Hey Sandy,
thanks a lot!
Exactly what I was looking for.
Have a great day,
Daniel
Hi Sandy,
I need to get back to you with one little thing:
I implemented the given code successfully and modified it to my needs.
However, how can I achieve that the search is done immediately based on the pre-defined values?
So if I use the code from you the user would still need to re-select the same date for example in order for searchBuilder to work.
Thanks!
Hi @schwaluck ,
Yes that is possible. SearchBuilder stores the values from the input elements in an internal property that can be referenced from the init function using
that.s.value
. I've edited the example to show how this can be done.Thanks,
Sandy
Hi Sandy,
thanks again for the quick response - it now works perfectly!
Enjoy your day,
Daniel