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.
Unfortunately, activation email could not send to your email. Please try again.

SelectionMode = SelectionMode.RangeSelection between months

Thread ID:

Created:

Updated:

Platform:

Replies:

131247 Jun 30,2017 07:36 AM Jul 3,2017 01:59 AM Xamarin.Forms 1
loading
Tags: SfCalendar
David Perera
Asked On June 30, 2017 07:36 AM

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,
            };
        }
    }
}

Rajkumar Ganesamoorthy [Syncfusion]
Replied On July 3, 2017 01:59 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;