Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Property - RadzenMultiDayView->AdvanceDays #1855

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions Radzen.Blazor/RadzenMultiDayView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Radzen.Blazor
public partial class RadzenMultiDayView : SchedulerViewBase
{
/// <inheritdoc />
public override string Icon => "calendar_view_week";
public override string Icon => "width_normal";

/// <inheritdoc />
[Parameter]
Expand Down Expand Up @@ -62,6 +62,13 @@ public partial class RadzenMultiDayView : SchedulerViewBase
/// <value>The number of days.</value>
[Parameter]
public int NumberOfDays { get; set; } = 2;

/// <summary>
/// Gets or sets number of days to advance when using prev / next. Set to <c>1</c> by default.
/// </summary>
/// <value>The number of days to advance.</value>
[Parameter]
public int AdvanceDays { get; set; } = 1;
/// <inheritdoc />
public override DateTime StartDate
{
Expand All @@ -85,21 +92,28 @@ public override string Title
{
get
{
return $"{StartDate.ToString(Scheduler.Culture.DateTimeFormat.ShortDatePattern)} - {EndDate.AddDays(-1).ToString(Scheduler.Culture.DateTimeFormat.ShortDatePattern)}";
if (StartDate == EndDate.AddDays(-1))
{
return $"{StartDate.ToString(Scheduler.Culture.DateTimeFormat.ShortDatePattern)}";
}
else
{
return $"{StartDate.ToString(Scheduler.Culture.DateTimeFormat.ShortDatePattern)} - {EndDate.AddDays(-1).ToString(Scheduler.Culture.DateTimeFormat.ShortDatePattern)}";
}
}
}


/// <inheritdoc />
public override DateTime Next()
{
return Scheduler.CurrentDate.Date.AddDays(NumberOfDays);
return Scheduler.CurrentDate.Date.AddDays(AdvanceDays);
}

/// <inheritdoc />
public override DateTime Prev()
{
return Scheduler.CurrentDate.Date.AddDays(-NumberOfDays);
return Scheduler.CurrentDate.Date.AddDays(-AdvanceDays);
}
}
}
4 changes: 2 additions & 2 deletions Radzen.Blazor/Rendering/DaySlotEvents.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ----------------------------------
// Rendering Algorithm - See Layout()
// ----------------------------------
// Note - Column, a property of the AppointmentDataExtended class, and colunCount are values that are set depending on todays overlapping appointments.
// Note - Column, a property of the AppointmentDataExtended class, and columnCount are values that are set depending on todays overlapping appointments.
// i.e., if there are no overlapping appointments, all appointments will be assigned a Column value of 1
// *** definition "Can fit in Column" - if an appointments "Start" is equal to or later than the last chronological appointments "End" in a column, this appointment can "fit in column" ***

Expand All @@ -15,7 +15,7 @@

// 1. Loop through all the appointments and assign which column they will be assigned (either existing or new)
// 1.1 If the appointment can fit in a column, it will be assigned that column value, otherwise a new column must be created to accomodate it
// 1.2 As the loop matures, there could be multiple columns that an appointment can fit in. It will select the one with the latest End time. This helps the view render more asthetically.
// 1.2 As the loop matures, there could be multiple columns that an appointment can fit in. It will select the one with the earliest End time. This helps the view render more asthetically.

// Once we know how many columns are required, we can set the width of each column (columnWidth = 90.0 / columnCount).

Expand Down
13 changes: 11 additions & 2 deletions RadzenBlazorDemos/Pages/SchedulerMultiDay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
{
<RadzenText TextStyle="TextStyle.Caption" Text="@($"(default)")" Style="margin-left:0.1rem;margin-top:0.5rem;" />
}
<div class="rz-w-25" />
<RadzenLabel Text="Advance days:" />
<RadzenSlider @bind-Value=@sliderAdvanceDays TValue="int" Min="1" Max="14" Style="margin-left:1.5rem;margin-right:1.5rem;" />
<RadzenLabel Text="@($"{sliderAdvanceDays}")" />
@if (sliderAdvanceDays == 1)
{
<RadzenText TextStyle="TextStyle.Caption" Text="@($"(default)")" Style="margin-left:0.1rem;margin-top:0.5rem;" />
}
</RadzenStack>

<RadzenScheduler @ref=@scheduler SlotRender=@OnSlotRender style="height: 768px;" TItem="Appointment" Data=@appointments StartProperty="Start" EndProperty="End"
Expand All @@ -16,7 +24,7 @@ SlotSelect=@OnSlotSelect AppointmentSelect=@OnAppointmentSelect AppointmentRende
AppointmentMove=@OnAppointmentMove >
<RadzenDayView />
<RadzenWeekView />
<RadzenMultiDayView NumberOfDays="@sliderNumberOfDays" />
<RadzenMultiDayView NumberOfDays="@sliderNumberOfDays" AdvanceDays="@sliderAdvanceDays" />
<RadzenMonthView />
</RadzenScheduler>

Expand All @@ -28,6 +36,7 @@ AppointmentMove=@OnAppointmentMove >
Dictionary<DateTime, string> events = new Dictionary<DateTime, string>();

int sliderNumberOfDays { get; set; } = 2;
int sliderAdvanceDays { get; set; } = 1;

IList<Appointment> appointments = new List<Appointment>
{
Expand All @@ -42,7 +51,7 @@ AppointmentMove=@OnAppointmentMove >

async Task NumberOfDaysChange()
{
await scheduler.Reload();
StateHasChanged();
}

void OnSlotRender(SchedulerSlotRenderEventArgs args)
Expand Down
Loading