We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Is possible to have enddate as optional in daterange picker?

Currently, I am using a Date Range Picker for selecting start and end date values. I would like to know if there is a possibility to have end date as optional value.

On select event I have enabled apply button when enddate is null and start date has value. While on click of apply event is not triggering change() function, hence no data is rendering in UI. Is there any way to save the date range picker with and without end date?


1 Reply

PK Priyanka Karthikeyan Syncfusion Team April 22, 2024 03:43 PM UTC

Hi Radha Velmurugan,

 

Thank you for reaching out to us.

 

By default, the daterangepicker processes based on both the start date and end date. However, if you need to work with just the start date and not select an end date, you can achieve this by using the select event. Below is an example where we set the start date value to be the same as the end date:

 

 <ejs-daterangepicker #daterange (select)="onSelect($event)"></ejs-daterangepicker>

 public onSelect(args:any) {

      this.daterange.startDate = new Date(args.startDate);

      this.daterange.endDate = new Date(args.startDate);

   }

 

 

Sample: https://stackblitz.com/edit/angular-iv1kze-uw9pqu?file=src%2Fapp.component.html,src%2Fapp.component.ts

 

API Reference: https://ej2.syncfusion.com/angular/documentation/api/daterangepicker/#select


Furthermore, if there is a possibility that we misunderstood your requirement, we would greatly appreciate it if you could provide us with further information about your scenario. This will help us align our understanding with your expectations and provide you with the best possible assistance.

 

Regards,

Priyanka K


Loader.
Live Chat Icon For mobile
Up arrow icon