ResourceHeaderTemplate

Hi,

We have are using a ResourceHeaderTemplate with our own razor component (HeaderComponent) inside, which is a summary of entries.  When a new entry is added or an existing entry updated we need our HeaderComponent to refresh to re-calculate the summary of entries - how is this possible?

 <ResourceHeaderTemplate>
            @{
                var userData = (context as Entry).ResourceData as UserData;
                <HeaderComponent.Web.Pages.Shared.Targets UserName="@userData.UserName" UserId="@userData.UserId" Date="@SfSchedule.SelectedDate"></HeaderComponent>
            }
        </ResourceHeaderTemplate>


Thanks,
Alex

1 Reply 1 reply marked as answer

AK Alagumeena Kalaiselvan Syncfusion Team June 15, 2020 08:36 AM UTC

Hi Alex, 

Greetings from Syncfusion support. 

We have checked your reported issue “How to refresh HeaderComponent to re-calculate the summary of entries” and we suggest you to use Scheduler DataBound event for your scenario. We have prepared a sample based on your requirement. Refer the below code for that. 
  
<div class="data">@CustomValue</div>  
  
<SfSchedule @ref="scheduleObj" TValue="AppointmentData" Width="100%" Height="650px" SelectedDate="@SelectedDate">  
    <ScheduleTemplates>  
        <ResourceHeaderTemplate>  
            @{  
                var userData = (context as AppointmentData).ResourceData as ResourceData;  
                <CustomComponent UserName="@userData.UserName" UserId="@userData.UserId" Date="@scheduleObj.SelectedDate">  
                </CustomComponent>  
            }  
        </ResourceHeaderTemplate>  
    </ScheduleTemplates>  
    <ScheduleEvents TValue="AppointmentData" DataBound="OnDataBound"></ScheduleEvents>  
    <ScheduleGroup Resources="@Resources"></ScheduleGroup>  
    <ScheduleResources>  
        <ScheduleResource DataSource="@DoctorsData" Field="DoctorId" Title="Doctor Name" Name="Doctors" TextField="UserName" IdField="UserId" ColorField="Color"></ScheduleResource>  
    </ScheduleResources>  
</SfSchedule>  
 
@code{  
    SfSchedule<AppointmentData> scheduleObj;  
    public DateTime SelectedDate { get; set; } = new DateTime(2020, 4, 4);  
    public string[] Resources { get; set; } = { "Doctors" };  
    public int i = 0;  
    public void OnDataBound(DataBoundEventArgs<AppointmentData> args)  
    {  
        SelectedDate = new DateTime(2020, 5, 5);  
        CustomValue = "Modified Schedule data" + i;   // You can re-calculate the custom component value  
        StateHasChanged();  
        i++;  
    }  
...  
}  

Also, you can get the sample using the following link. 

Regards 
Alagumeena.K 


Marked as answer
Loader.
Up arrow icon