Hi,
I have the scheduler looking exactly how I want with custom cell dimensions:
The issue is, when I filter the resources to only show one, the column becomes 100% wide:
How can I force the column to retain the set width (236px)? Ideally the rest is filled with whitespace.
Please advise if possible.
Hi Jack,
You can achieve your goal by updating the cssClass when there is just one resource in schedule using Schedule's dataBound event, as shown in the excerpt below.
Sample: https://stackblitz.com/edit/react-schedule-fixed-width-of-resource?file=index.js
Api: https://ej2.syncfusion.com/react/documentation/api/schedule/#databound
[index.js]
|
function TimelineGrouping() { const categoryData = [ { text: 'Nancy', id: 1, groupId: 1, color: '#df5286' }, { text: 'Steven', id: 2, groupId: 1, color: '#7fa900' }, ]; let resourceCount; function Onclick() { var schedule = document.querySelector('.e-schedule').ej2_instances[0]; schedule.removeResource(2, 'Categories'); }
function onDataBound() { var schedule = document.querySelector('.e-schedule').ej2_instances[0]; resourceCount = schedule.resourceCollection[0].dataSource.length; if(schedule.resourceCollection[0].dataSource.length == 1) { schedule.cssClass = "single-resources"; } } return (<div className='schedule-control-section'> <div className='col-lg-12 control-section'> <div className='control-wrapper'> <button onClick={Onclick.bind(this)}>Remove resource</button> <ScheduleComponent cssClass="schedule-cell-dimension dataBound={onDataBound.bind(this)}> </ScheduleComponent> </div> </div> </div>); } |
[index.css]
|
.schedule-cell-dimension.e-schedule .e-vertical-view .e-date-header-wrap table col, .schedule-cell-dimension.e-schedule .e-vertical-view .e-content-wrap table col { width:236px; }
.schedule-cell-dimension.e-schedule .e-month-view .e-work-cells, .schedule-cell-dimension.e-schedule .e-month-view .e-date-header-wrap table col { width: 236px; }
.single-resources .e-schedule-table.e-content-table, .single-resources .e-date-header-container { width: calc(100% - 236*2px); } |
Regards,
Swathi Ravi
Hi Ravi,
That worked well for a single resource, however in my particular case, the user can select 1 or many resources to see.
Therefore I required a more dynamic solution, which I will share in case it helps others:
Hi Jack,
Thank you for sharing your dynamic solution with us. We appreciate your contribution and are glad that you were able to find a solution that suits your specific case. Your input will indeed be helpful to others facing similar challenges. If you have any further questions or need additional assistance, please feel free to ask.
Regards,
Vinitha