Is it possible to make the date columns narrower in Month view? As shown in the screenshot below, I am able to see September 1 - 17 with the default width. I would like to reduce the column width of each day by a little bit so that my users can see more days while in month view without scrolling.
Is it possible to control the date column width?
Hi Justine,
Greetings from Syncfusion Support
We have validated your reported query and suspect that you want to remove the horizontal scroller while rendering scheduler and achieved it by using eventRendered and actionComplete event of our schedule with following CSS. We have prepared the below sample for your reference with your code snippet which you shared in one of your previous incident.
https://stackblitz.com/edit/react-timelinemonth-without-horizontal-scroll
.e-schedule
.e-timeline-month-view
.e-date-header-wrap
table
col,
.e-schedule
.e-timeline-month-view
.e-content-wrap
table
col {
width: auto
!important;
}
onActionComplete(args) {
if (
args.requestType === 'viewNavigate' ||
args.requestType === 'dateNavigate'
) {
this.dayWidth = null;
}
}
onEventRendered(args) {
if (this.currentView === 'TimelineMonth') {
this.dayWidth =
this.dayWidth ??
document.querySelector('.e-date-header-wrap').clientWidth /
(new
Date(
this.selectedDate.getFullYear(),
this.selectedDate.getMonth() + 1,
0
).getDate() *
this.scheduleObj.activeViewOptions.interval); //To calculate the width of a work cell
const
diffInDay = args.data.data.count; //To calculate the number of days an event rendered.
const
td = document.querySelector(
'.e-work-cells[data-date="' +
this.resetTime(args.data.StartTime).getTime() +
'"]'
); //To find the work cell element in which the appointment started
const
left = td ? td.offsetLeft : args.element.style.left; //To calculate the left position of that work cell
args.element.style.left = left + 'px'; //To assign the above left position to the appointment element
args.element.style.width = diffInDay * this.dayWidth + 'px'; //To set width for the appointment element.
}
}
Kindly try with the above sample and get back to us if you need any further assistance.
Regards,
Vinitha
How can I accomplish this in a React functional component? Also, I do not want the cells to be auto width. Instead, I want to be able to set them to EXACTLY 25px or 70px or whatever measurement I want to use.
This doesn't seem to work for me.
I have set the following styles, attempting to set the columns to 40px wide:
I've added this ref to my functional component code:
I also have a variable for the schedule component by using this:
In the eventRendered event, I have added this code.
Since I am using Typescript, many of the provided lines of code were reported as unsafe due to the fact various things could be undefined. Also, React reports that the "td" has no offsetLeft property. I had to make minor adjustments to the way it was written.
Finally, I also added the actionComplete event:
The issue now is that when the window is resized or the layout changes, the events are the incorrect width.
Notice in this first screenshot that the layout is correct for this event. It starts on the 3rd and ends on the 9th.
However, when I expand my main menu on the left side of the website, it shifts the scheduler over and causes the event to be the incorrect width. Notice that it no longer starts EXACTLY on the 3rd and now ends near the end of the 10th.
Hi Justin,
Greetings from Syncfusion Support.
We suggest you to call refreshEvents or refreshLayout method inside main menu layout resize event to resolve issue.
Refresh (method): https://ej2.syncfusion.com/react/documentation/api/schedule/#refreshlayout
https://ej2.syncfusion.com/react/documentation/api/schedule/#refreshevents
Kindly
refer the above solution and get back to us for further assistance.
Regards,
Vinitha