Date format not applied throughout the control

When I set the date format on the Schedule control to "dd. MMM yyyy" it gets shown properly in the header datepicker but not in the timeline header. Am I missing something 


Image_9358_1727863292736


7 Replies 1 reply marked as answer

RR Ram Raju Elaiyaperumal Syncfusion Team October 3, 2024 02:58 PM UTC

Hi Thomas Pentenrieder,

You can customize the header row of timeline header rows and display formatted text on each individual header rows using the built-in template option available within the HeaderRowDirective.

Kindly check on the below demo and documentation for better understanding:


Demo: https://ej2.syncfusion.com/react/demos/#/fluent2/schedule/header-rows

Documentation: https://ej2.syncfusion.com/react/documentation/schedule/header-rows

Regards,

Ram



TP Thomas Pentenrieder October 3, 2024 03:50 PM UTC

but why is a date format only applied partially on the schedule control. that doesn't make much sense imo.



VR Vijay Ravi Syncfusion Team October 4, 2024 09:45 AM UTC

Hi Thomas,

Based on your requirements, we recommend using the dateHeaderTemplate to customize the date header format, as demonstrated in the code snippet below. Please refer to the provided user guide and sample for further reference. We encourage you to try it out.
 

[index.js]
 

import { extend, Internationalization } from '@syncfusion/ej2-base';

import * as dataSource from './datasource.json';

/**

 * schedule timeline resource grouping sample

 */

const TimelineGrouping = () => {

    let instance = new Internationalization();

    const getDateHeaderText = (value) => {

        return instance.formatDate(value, { format: 'dd.MMM yyyy' });

    };

    const dateHeaderTemplate = (props) => {

        return (<div>

        <div>{getDateHeaderText(props.date)}</div>

      </div>);

    };

    return (<div className='schedule-control-section'>

            <div className='col-lg-12 control-section'>

                <div className='control-wrapper'>

                    <ScheduleComponent dateFormat="dd.MMM yyyy" dateHeaderTemplate={dateHeaderTemplate}>

                    </ScheduleComponent>

                </div>

            </div>

        </div>);

};

export default TimelineGrouping;


DateHeaderTemplate UG: https://ej2.syncfusion.com/react/documentation/schedule/header-bar#using-date-header-template

dateHeaderTemplate api: https://ej2.syncfusion.com/react/documentation/api/schedule/#dateheadertemplate

Sample link: https://stackblitz.com/edit/react-yhv4zr-jmnj7s?file=index.js

Output screenshot:
 



Regards,

Vijay



TP Thomas Pentenrieder October 11, 2024 01:25 PM UTC

Thanks, but that will also override the Month Timeline View dateheader where there's only space for the day number and not the whole date. any way to exclude this view?

Image_1591_1728653130530



SR Swathi Ravi Syncfusion Team October 14, 2024 02:46 PM UTC

Hi Thoms,

Thank you for your question regarding the TimelineMonth view in the Schedule component.

You can indeed exclude the dateHeaderTemplate from the TimelineMonth view without affecting the other views.

return (<div className='schedule-control-section'>
            <div className='col-lg-12 control-section'>
                <div className='control-wrapper'>
                    <ScheduleComponent cssClass='timeline-resource-grouping' width='100%' height='650px' selectedDate={new Date(2023, 0, 4)} currentView='TimelineWeek' >
                        <ViewsDirective>
                            <ViewDirective option='TimelineDay' dateHeaderTemplate={dateHeaderTemplate}/>
                            <ViewDirective option='TimelineWeek' dateHeaderTemplate={dateHeaderTemplate}/>
                            <ViewDirective option='TimelineWorkWeek' dateHeaderTemplate={dateHeaderTemplate}/>
                            <ViewDirective option='TimelineMonth'/>
                            <ViewDirective option='Agenda'  dateHeaderTemplate={dateHeaderTemplate}/>
                        </ViewsDirective>
                        <Inject services={[TimelineViews, TimelineMonth, Agenda, Resize, DragAndDrop]}/>
                    </ScheduleComponent>
                </div>
            </div>
        </div>);
};


If you have any further questions or need additional assistance, please feel free to reach out. We're here to help!


Regards,
Swathi

Marked as answer

TP Thomas Pentenrieder October 15, 2024 01:04 PM UTC

applying it on ViewDirective worked, thanks!



SR Swathi Ravi Syncfusion Team October 16, 2024 06:13 AM UTC

Hi Thomas,


You are welcome. We are glad to hear that our provided solution was worked for you. Get back to us if you need any further assistance.


Regards,
Swathi


Loader.
Up arrow icon