Page 1 of 2

Datepicker within collapsible

Posted: Tue Jul 22, 2014 5:46 am
by Aeneas McBurney

I am trying to set the value of a datepicker inside a collapsible on page load but its not working. This is the code I have which I know works when date is outside collapsible.

var dateTo = Appery("dateTo");
dateTo.setProperty("defaultDateValue", $.datepicker.formatDate(dateElement.datepicker_dataPickerOptions.dateFormat, new Date()));

Also how do I get the current date value of a datepicker with js?

Also how do you use date in a gte where clause? This doesn't work

{_createdAt:{$gte:'2014-07-10'}}

Thanks,
Aeneas


Datepicker within collapsible

Posted: Tue Jul 22, 2014 11:12 am
by Kateryna Grynko

Hi Aeneas,

Here is how to get a date from datepicker named mobiledatepickerName:prevar val = $("[name=mobiledatepickerName] input").val();/pre
Please convert it to ISO format before using it in request, then your code will look as follows:prereturn '{"_createdAt":{"$gte":"' + val.toISOString() + '"}}';/pre


Datepicker within collapsible

Posted: Tue Jul 22, 2014 9:54 pm
by Aeneas McBurney

Hi Katya, thanks for your response.

When I run this script it fails on the last line. So the first alert returns the correct date and the 2nd alert crashes the script.

var dateto = $("[name=dateTo] input").val();
alert(dateto);
alert(dateto.toISOString());

Also if you could answer the first part of my question above on how to set default date within a collapsible.

Thanks,
Aeneas


Datepicker within collapsible

Posted: Wed Jul 23, 2014 4:25 am
by Yurii Orishchuk

Hi Aeneas,

Please use following code instead of yours:

pre

var dateto = $("[name=dateTo] input").val();
alert(dateto);
var dateObject = new Date(dateto);
alert(dateObject.toISOString());

/pre

Regards.


Datepicker within collapsible

Posted: Wed Jul 23, 2014 6:17 am
by Aeneas McBurney

Hi Yurri,

That works thanks!

How about my other question in regards to setting default date in collapsible.........

I am trying to set the value of a datepicker inside a collapsible on page load but its not working. This is the code I have which I know works when date is outside collapsible.

var dateTo = Appery("dateTo");
dateTo.setProperty("defaultDateValue", $.datepicker.formatDate(dateElement.datepicker_dataPickerOptions.dateFormat, new Date()));


Datepicker within collapsible

Posted: Wed Jul 23, 2014 9:40 am
by Aeneas McBurney

I have managed to get the date in correct format however when I pass to the query its returning no data. Please see 2 screenshots attached with first being with no ate filter clearly showing a date that should be included in the next screen shot where I have the date filter.

Data....
Image

No data....
Image


Datepicker within collapsible

Posted: Wed Jul 23, 2014 7:08 pm
by Evgene Karachevtsev

Hello Aeneas,

Could you please try this code:
pre{"_createdAt": {"$gte":{"$date":"2012-11-14T21:54:56.757Z"}}}/pre


Datepicker within collapsible

Posted: Wed Jul 23, 2014 9:44 pm
by Aeneas McBurney

That works great thanks!

Now how do I set the default date of a datepicker within a collapsible?


Datepicker within collapsible

Posted: Wed Jul 23, 2014 10:53 pm
by Alena Prykhodko

You can set default value in Properties (set the Default Date property). You can also set the default value via JavaScript -- for example on page load.


Datepicker within collapsible

Posted: Wed Jul 23, 2014 11:08 pm
by Aeneas McBurney

Hi Alena and thanks for your response.

I am trying to set it via javascript as per my original post which was.....

I am trying to set the value of a datepicker inside a collapsible on page load but its not working. This is the code I have which I know works when date is outside collapsible.

var dateTo = Appery("dateTo");
dateTo.setProperty("defaultDateValue", $.datepicker.formatDate(dateElement.datepicker_dataPickerOptions.dateFormat, new Date()));