bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
54 stars 6 forks source link

Return value from `headerRenderer` in `MonthView` not used. #10062

Open chuckn0rris opened 2 months ago

chuckn0rris commented 2 months ago

Try to specify any renderer, even empty method. See the line is disapeared. According to docs, we do not expect to have any value returned from that method.

Forum post

const calendar = new Calendar({
    appendTo : targetElement,
    height   : 560,
    date     : new Date(2020, 8, 1),
    modes    : {
        day    : null,
        week   : null,
        month  : {

            headerRenderer: (a,b,c) => {

            }
        },
        year   : null,
        agenda : null
    },
    events : [
        { startDate : '2020-09-02T07:00', duration : 5, durationUnit : 'h', name : 'Walk the dog', eventColor : 'yellow' },
        { startDate : '2020-09-10T09:00', duration : 2, durationUnit : 'h', name : 'Buy masks', eventColor : 'orange' },
        { startDate : '2020-09-14T07:00', duration : 1, durationUnit : 'h', name : 'Zoom meeting', eventColor : 'deep-orange' },
        { startDate : '2020-09-25T09:00', duration : 1, durationUnit : 'h', name : 'Get a haircut', eventColor : 'gray' }
    ]
});
chuckn0rris commented 18 hours ago

Not a bug. Expected to return something from a headerRenderer to be shown. Nothing returned - nothing shown.

ExtAnimal commented 18 hours ago

The docs are bad. We should make them true.

I suggest in CalendarPanel.js:

            if (me.headerRenderer) {
                cell.innerHTML = '';
                const header = me.callback(me.headerRenderer, me, [cell, columnIndex, cellDay]);
                if (header) {
                    if (typeof header === 'string') {
                        DomHelper.setInnerText(cell, header);
                    }
                    else {
                        DomHelper.createElement({
                            ...header,
                            parent : cell
                        });
                    }
            }
            else {
                DomHelper.setInnerText(cell, me.shortDayNames[cellDay]);
            }