NativeScript / nativescript-datetimepicker

Plugin with date and time picking fields
Apache License 2.0
27 stars 26 forks source link

no events #67

Open kapil9-10 opened 4 years ago

kapil9-10 commented 4 years ago

is there any event which triggers on when you click on ok button on datePicker

giulianimartini commented 4 years ago

Hey @kapil9-10,

Did you check the Getting/Setting Date and Time section on Features?

You can listen to the dateChange event on DatePickerField.

Here is an example of using it with vue binding:

<DatePickerField @dateChange="onDateTimeChange1" :date="dateTime1"></DatePickerField>

Where dateTime1 is your date, for example:

data() { return { dateTime1: new Date(), } },

Then in your methods:

methods: { onDateTimeChange1: function(args) { this.dateTime1 = args.value; },

So it will get the date on args.value when you click the 'OK' button. If you click 'Cancel', it will no get the value and it will keep the old one.

Hope it helps.

kapil9-10 commented 4 years ago

thanks for help,, one more query how will I know when he just scroll or clicked ok

giulianimartini commented 4 years ago

Hi @kapil9-10,

good to know it helped you.

I don't know if there's an event to capture the scroll, but the click is get on the dateChange event. So, as I explained in the last post, when you click on 'OK', it will get the value that you have set. Otherwise, if you click 'Cancel', it will get the old value. So you can get the 'OK' click on dateChange event =)

Hope it helps!