How to get the date range for the current view?

1 Answer 21 Views
Scheduler
Mike
Top achievements
Rank 1
Iron
Iron
Mike asked on 12 Feb 2025, 10:30 PM

How can I get the start and end dates that are displayed in the current view?  I understand that there is a date changed event, but that doesn't give me the entire date range of what is currently being displayed.  I'd like to use that date range to then re-query the database and only pull back the events for that specific range.  I currently can't find a way to get that information.

 

1 Answer, 1 is accepted

Sort by
0
Hristian Stefanov
Telerik team
answered on 17 Feb 2025, 09:22 AM

Hi Mike,

To determine the start and end dates for the current view in the Telerik UI for Blazor Scheduler, you can bind the Date and View parameters to variables. This approach allows you to calculate the date range based on the current view settings.

Here's how you can achieve this:

  1. Bind the Date and View Parameters:

    Bind the Date and View parameters of the Scheduler to variables in your component. This helps you identify the current view and the date it is centered on.

    <TelerikScheduler @bind-Date="SchedulerDate" @bind-View="SchedulerView">
        <!-- Your scheduler configuration -->
    </TelerikScheduler>
    
    @code {
        private DateTime SchedulerDate { get; set; } = DateTime.Today;
        private SchedulerView SchedulerView { get; set; } = SchedulerView.Week;
    }
  2. Calculate the Start and End Dates:

    Use the bound SchedulerDate and SchedulerView to calculate the start and end dates for the current view. For instance, if the view is set to a week, calculate the start date by finding the previous Monday and the end date by finding the next Sunday.

  3. Re-query the Database:

    With the calculated start and end dates, you can query your database for events within that range, ensuring you only retrieve the relevant events.

    Regards,
    Hristian Stefanov
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    Tags
    Scheduler
    Asked by
    Mike
    Top achievements
    Rank 1
    Iron
    Iron
    Answers by
    Hristian Stefanov
    Telerik team
    Share this question
    or