highlight the current date for the whole column

hello syncfusion team 

is there a way to highlight current date for the whole column
timelineview month.. i haven't seen any options available..


Example: this part the whole column of the current date must be highlighted


1 Reply

RR Ram Raju Elaiyaperumal Syncfusion Team January 24, 2024 12:08 PM UTC

Hi Arnie Reyes,


Based on your query, it appears you are looking to highlight the entire column of the current date in the TimelineView Month. While there may not be a direct option to achieve this, you can utilize the OnRenderCell event which is triggered when each cell is rendered.


By adding a check within this event to determine if the date is the current date, you can add a custom CSS class to the cell. This class can then be styled to highlight the cell, effectively highlighting the entire column for the current date.


Here is a sample implementation:


<SfSchedule TValue="AppointmentData" Height="700px">

    <ScheduleEvents TValue="AppointmentData" OnRenderCell="OnRenderCell"></ScheduleEvents>

    <ScheduleGroup Resources="@Resources"></ScheduleGroup>

    <ScheduleResources>

        <ScheduleResource TItem="ResourceData" TValue="int[]" DataSource="@OwnersData" Field="OwnerId" Title="Owner" Name="Owners" TextField="OwnerText" IdField="Id" ColorField="OwnerColor" AllowMultiple="true"></ScheduleResource>

    </ScheduleResources>

    <ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings>

    <ScheduleViews>

        <ScheduleView Option="View.TimelineMonth"></ScheduleView>

        <ScheduleView Option="View.TimelineWeek"></ScheduleView>

    </ScheduleViews>

</SfSchedule>

 

<style>

    .e-work-cells.e-work-days.custom-class {

        background-color: peachpuff !important;

    }

</style>

 


DateTime CurrentDate = DateTime.Today;  

 

public void OnRenderCell(RenderCellEventArgs args)

    {

        if (args.ElementType == ElementType.MonthCells && args.Date.Date == CurrentDate)

        {

            args.CssClasses = new List<string>(CustomClass); //The default work hours color is changed to ivory color

        }

    }


In this code, the OnRenderCell event checks if the date of the cell is the current date. If it is, it adds a custom CSS class to the cell. The CSS class is then styled to change the background color of the cell.


For Your convenience we have created a sample based on your requirement, Kindly check on the sample: https://blazorplayground.syncfusion.com/BDLJXsVKoyxfOTfs


We hope this solution meets your requirements. Please let us know if you have any further questions or concerns.



Regards,

Ram


Loader.
Up arrow icon