How do you toggle between a GroupBy/Resource view and a normal view

Alle presentations that use <ScheduleGroup> have at least one <ScheduleResource>.
Sample projects I have found show how you can add more resources (for instances , more Calendar types), but you cannot uncheck all calendars and view all events without a Resource row in the Scheduler. As soon as you uncheck the last Calendar type, the application crashes. That is probably why all the demos have 1 checkbox disabled, so you cannot uncheck the final Calendar type.

But I do want to be able to show both type of presentations - grouped and ungrouped - to the user with a click of a button: 

1 Reply 1 reply marked as answer

AK Alagumeena Kalaiselvan Syncfusion Team July 28, 2020 12:35 PM UTC

Hi Roland, 

Greetings from Syncfusion support. 

Query: How to toggle between group by  resource view and normal view 

We have checked your reported query and you can toggle between grouped resource view and normal view by customizing the Resources property inside ScheduleGroup tag. Refer the below code for that. 


<button class="e-btn" @onclick="ChangeResourceGroup">@Content</button> 
 
<SfSchedule TValue="AppointmentData" Height="550px" SelectedDate="@(new DateTime(2020, 1, 31))"> 
    <ScheduleGroup Resources="@Resources"></ScheduleGroup> 
    <ScheduleResources> 
        <ScheduleResource TValue="ResourceData" DataSource="@OwnersData" Field="OwnerId" Title="Owner" Name="Owners" TextField="OwnerText" IdField="Id" ColorField="OwnerColor" AllowMultiple="true"></ScheduleResource> 
    </ScheduleResources> 
    <ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings> 
</SfSchedule> 
 
@code{ 
    public string Content { get; set; } = "Click to UnGroup"; 
    public string[] Resources { get; set; } = { "Owners" }; 
    public void ChangeResourceGroup()             // To Toggle between Grouped and normal view 
    {   
        if(Content == "Click to UnGroup") 
        { 
            Resources = new string[] { }; 
            Content = "Click to Group"; 
        } 
        else 
        { 
            Resources = new string[] { "Owners" }; 
            Content = "Click to UnGroup"; 
        } 
        StateHasChanged(); 
    } 
} 

Also, you can download this sample using the following link 

Please let us know if you need further assistance. 

Regards 
Alagumeena.K 


Marked as answer
Loader.
Up arrow icon