How do I identify which Preset was selected from the ValueChange event

I have an SfDateRangePicker with presets:

    <SfDateRangePicker TValue="DateTime" Placeholder="@localizer[Resources.App.ReportDateRange]" FloatLabelType="FloatLabelType.Always"
                       ShowClearButton="false" ShowTodayButton="true" StartDate="@FromDateTime" EndDate="@ToDateTime">
        <DateRangePickerEvents TValue="DateTime" ValueChange="@OnValueChange"></DateRangePickerEvents>
        <DateRangePickerPresets>
            <DateRangePickerPreset Label="@localizer[Resources.App.ThisWeek]" Start="@WeekStart" End="@WeekEnd"></DateRangePickerPreset>
            <DateRangePickerPreset Label="@localizer[Resources.App.ThisMonth]" Start="@MonthStart" End="@MonthEnd"></DateRangePickerPreset>
            <DateRangePickerPreset Label="@localizer[Resources.App.ThisQuarter]" Start="@QuarterStart" End="@QuarterEnd"></DateRangePickerPreset>
            <DateRangePickerPreset Label="@localizer[Resources.App.ThisYear]" Start="@YearStart" End="@YearEnd"></DateRangePickerPreset>
            <DateRangePickerPreset Label="@localizer[Resources.App.LastWeek]" Start="@LastWeekStart" End="@LastWeekEnd"></DateRangePickerPreset>
            <DateRangePickerPreset Label="@localizer[Resources.App.LastMonth]" Start="@LastMonthStart" End="@LastMonthEnd"></DateRangePickerPreset>
            <DateRangePickerPreset Label="@localizer[Resources.App.LastQuarter]" Start="@LastQuarterStart" End="@LastQuarterEnd"></DateRangePickerPreset>
            <DateRangePickerPreset Label="@localizer[Resources.App.LastYear]" Start="@LastYearStart" End="@LastYearEnd"></DateRangePickerPreset>
        </DateRangePickerPresets>
    </SfDateRangePicker>



I'd like to persist the preset selection. I don't want to save the actual start and end dates, but which preset was selected (ideally in the OnChange event). Is there a way to do this?  Also, I'm using localization so I'd prefer not to use the label to identify the preset or try to match up which preset was selected by comparing a long list of start and end dates.

Ideally, a Value property could be added to the DateRangePickerPreset and the selected DateRangePickerPreset could be a property of the RangePickerEventArgs (set to null of a custom date range was entered).

Thanks,
Craig


2 Replies

PM Ponmani Murugaiyan Syncfusion Team January 10, 2022 03:50 PM UTC

Hi Craig, 

Currently we are checking the reported query, we will update further details in 2 business days (January 12, 2022). We appreciate your patience until then. 

Regards, 
Ponmani M 



PM Ponmani Murugaiyan Syncfusion Team January 13, 2022 12:26 PM UTC

Hi Craig, 

Greetings from Syncfusion support. 

Query: How do I identify which Preset was selected from the ValueChange event. 
 
Using DaySpan argument in ValueChange event you can identify which presets was selected. 

 


Regards, 
Ponmani M 


Loader.
Up arrow icon