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

SelectionMode = SelectionMode.RangeSelection between months

Hi,

I am using the Calendar component and I try just simply to have a calendar in which I can select a init and end dates.

The SelectionMode = SelectionMode.MultiSelection, does not suit since you can select more than two dates.

So I am using SelectionMode = SelectionMode.RangeSelection. I am trying this on iOS for the moment. Basically I can only select the dates within the month, and if I press another month the selection goes away. Moreover, the application closes (I think it crashes but I do not see any exceptions logged), when you press and maintain a day and you put your finger over the arrows of going to the previous or next month.

How can I achieve my requirement of selecting Init and End Date with this component within months or even years?

I need this to be solved as soon as possible since I need to deliver to my clients.

Thank you very much,

PD: The code is just:
    public class CalendarView : BaseContentPage
    {
        public event EventHandler AcceptClicked;
        SfCalendar calendar;

        DateTime _startDate, _endDate;

        public CalendarView(DateTime startDate, DateTime endDate)
        {
            ToolbarItems.Add(new ToolbarItem(AppResources.OK, "", AcceptButton));
            ToolbarItems.Add(new ToolbarItem(AppResources.Cancel, "", CancelButton));
            this._startDate = startDate;
            this._endDate = startDate;

            Content = GetLayout();
        }

        private void AcceptButton(object sender, EventArgs e)
        {
            AcceptButton();
        }

        private void CancelButton(object sender, EventArgs e)
        {
            CancelButton();
        }

        private async void AcceptButton()
        {
            DateFilterEventArgs args = new DateFilterEventArgs();

            try
            {
                DateTime startDate = calendar.SelectedDates[0];
                DateTime endDate = calendar.SelectedDates[1];

                bool fechaIncorrecta = (startDate.Date > endDate.Date);
                args.startDate = fechaIncorrecta ? _startDate : startDate.Date;//do not change the dates if the user puts wrong dates
                args.endDate = fechaIncorrecta ? _endDate : endDate.Date;
                AcceptClicked(null, args);
                await Navigation.PopModalAsync();
            }
            catch (Exception ex)
            {
                ((ViewModels.CalendarVM)this.BindingContext).DialogService.ShowError("SELECCIONAR DOS FECHAS");
            }

            
        }

        private async void CancelButton()
        {
            await Navigation.PopModalAsync();
        }

        private View GetLayout()
        {
            return calendar = new SfCalendar()
            {
                MaxDate = DatesHelper.GetDateTimeNow(),
                SelectionMode = SelectionMode.RangeSelection,
            };
        }
    }
}

1 Reply

RG Rajkumar Ganesamoorthy Syncfusion Team July 3, 2017 05:59 AM UTC

Hi David,

Thank you for contacting Syncfusion Support.

We have analyzed the reported requirement in our side. In our current implementation we don't have support for "RangeSelection in multiple months". We have already logged feature request for this. It will availble in any of our upcoming release. Meanwhile we have prepared a sample which will demonstrate about "How to achieve your requirement by MultipleSelection". Please find the sample from below link.

Sample: http://www.syncfusion.com/downloads/support/forum/131247/ze/DemoSample-1843951012

Regards,
Rajkumar G

Loader.
Live Chat Icon For mobile
Up arrow icon