mengxiong10 / vue-datepicker-next

A datepicker / datetimepicker component for Vue3
https://mengxiong10.github.io/vue-datepicker-next/
MIT License
147 stars 34 forks source link

Option to set field value to empty strings when cleared (clearable = true) #32

Closed eaglebush closed 1 year ago

eaglebush commented 1 year ago

What problem does this feature solve? Clearing the picker by clicking the x button will set the value to null when bound. My use-case is that the date will be used as a filter to query via REST. This is being converted to JSON via JSON.stringify. I would like to get rid of the nulls automatically without having to set all object property to its default value, which in my case, is blank string.

What does the proposed API look like? clearDefault: "" clearDefault: null

mengxiong10 commented 1 year ago

You can convert it when use it. JSON.string(value || '')

eaglebush commented 1 year ago

Yes, I have already done that. The feature I am asking if it will be feasible to add an option to set the bound v-model property rather than doing this everytime before a REST query:

        filter.trandate_from ??= "";
        filter.trandate_to ??= "";
        filter.shipdate_from ??= "";
        filter.shipdate_to ??= "";

... because clearing the datetimepicker will set the bound v-model to null.

Thanks!