Maintain SelectedDate when change ViewModes

4 posts, 0 answers
  1. Maciej Poskrop
    Maciej Poskrop avatar
    9 posts
    Member since:
    Feb 2018

    Posted 18 Apr 2019 Link to this post

    Hi, I started playing with Scheduler, and I discover that there is hard to maintain selectedDate when I change between view modes.
    For example, I set Month view mode, next I select interesting date, and want to see day view for this date. How do you do this?
    When I change view mode to DayView, SelectedDay event clears date seleced in MonthView mode.
    Maybe this is some bug, but how creators intended to use those controls for such purpose?
    Maybe is there some example of such case of those controls?

    And also what is DisplayDate, whoat is diff to SelectedDate, I didn't find it in docs.

  2. Lance | Manager - Technical Support
    Admin
    Lance | Manager - Technical Support avatar
    1101 posts

    Posted 19 Apr 2019 Link to this post

    Hi Maciej,

    Different views wil have slightly different values for SelectedDate because of the granuality of that view (e.g. a particular view might need to change the Hour component when the last view was only concerned with Day component).

    To maintain a single value, you can keep a SelectedDate property in your view model/code that has a specific value. Use that property to set the control's SelectedDate property after the view changes.

    For example, a one-way binding:

    <telerikInput:RadCalendar x:Name="calendar" ViewMode="Month" SelectedDate="{Binding MySelectedDate}" />

    To answer your quesiton about the difference between SelectedDate and DisplayDate, DisplayDate is set t make the control go to the area of the view that has that date, even if you don't force a selection. For example, DisplayDate would be DateTime.Noow, while SelectedDate can be tomorrow.

    You can learn more about DisplayDate in the Date Properties documentation.


    If you have any trouble or have scenarion specific questions, feel free to open a Support Ticket and share the code that you're using so that we can assist further.

    Regards,
    Lance | Technical Support Engineer, Principal
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. John
    John avatar
    1 posts
    Member since:
    Sep 2018

    Posted 13 Jun 2019 in reply to Lance | Manager - Technical Support Link to this post

    Hey Lance,

    I'm not sure if this applies to the original post, but using a property and binding to SelectedDate of RadCalendar does not fix this issue. When switching to Day view the SelectedDate is set to the previous value and not the one just selected from Month view. I would attach a project that reproduces this, but i am unable to attach zip file here. I can open a new ticket if it's needed. Steps follow:

     

    1. Observe the selected date on Day view (ex. the 11th).

    2. Tap the Month button to move to Month view.

    3. The 11th is selected. Select another day(ex. the 15th).

    4. Tap the Day button to move to Day view.

    5. Observe the selected date is again the 11th.

    6. Tap Month and observe the selected date stays the 11th.

    What's happening in the bound SelectedDate property in the view model is that the setter is hit to set the date to the 15th. When the view moves to day view again, the setter is hit again automatically setting the date to the previous value from day view(the 11th). There is no way that this is the intended behavior.

  4. Lance | Manager - Technical Support
    Admin
    Lance | Manager - Technical Support avatar
    1101 posts

    Posted 13 Jun 2019 Link to this post

    Hi John,

    I have created a Support Ticket for you so you can get direct assistance from the developers. You can find the ticket on your My Support Tickets page.

    I think this should be straightforward to recreate. However, I recommend attaching a repro project so that we can have the exact setup you're using.


    @Maciej

    I accidentally opened the ticket under your account because you were the creator of the thread. I have already reassigned it to John, please disregard any notifications you may have received. My apologies for any confusion that may have caused.

    Regards,
    Lance | Technical Support Engineer, Principal
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top