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
53 stars 6 forks source link

loadInlineData does not work if current data is empty and refresh is suspended #2152

Closed pmiklashevych closed 7 months ago

pmiklashevych commented 3 years ago

https://www.bryntum.com/forum/viewtopic.php?p=80936#p80936

Scheduler/examples/basic/app.js

const scheduler = new Scheduler({
    appendTo  : 'container',
    minHeight : '20em',
    project   : {
        resourcesData : [],
        eventsData    : []
    },
    startDate        : new Date(2017, 0, 1, 6),
    endDate          : new Date(2017, 0, 1, 20),
    viewPreset       : 'hourAndDay',
    rowHeight        : 50,
    barMargin        : 5,
    multiEventSelect : true,

    columns : [
        { text : 'Name', field : 'name', width : 130 }
    ],

    tbar : {
        items : [
            {
                type  : 'button',
                text  : 'Load data',
                listeners : {
                    click : 'up.onDataLoad'
                }
            }
        ]
    },

    onDataLoad() {
        // comment out suspendRefresh/resumeRefresh to see that loading works
        scheduler.suspendRefresh();
        scheduler.project.loadInlineData({
            resourcesData : resources,
            eventsData    : events
        }).then(() => {
            scheduler.resumeRefresh(true);
        });
    }
});

Go to http://lh/bryntum-suite/scheduler/examples/basic/ Click "Load data" button See nothing is shown in the scheduler => Check values in console:

scheduler.refreshSuspended
//0
scheduler.project.eventStore.count
//8
scheduler.project.resourceStore.count
//10

See data is in the store, refresh is not suspended.

Снимок экрана 2020-12-21 в 19 47 33

It works when remove suspendRefresh/resumeRefresh

    onDataLoad() {
        //scheduler.suspendRefresh();
        scheduler.project.loadInlineData({
            resourcesData : resources,
            eventsData    : events
        }).then(() => {
            //scheduler.resumeRefresh(true);
        });
    }

or when suspendRefresh/resumeRefresh is there and current data is present

const scheduler = new Scheduler({
    appendTo  : 'container',
    minHeight : '20em',
    project   : {
        resourcesData : [{ id : 'r1', name : 'Mike' }],
        eventsData    : [{
            id         : 1,
            resourceId : 'r1',
            startDate  : new Date(2017, 0, 1, 10),
            endDate    : new Date(2017, 0, 1, 12),
            name       : 'Click me',
            iconCls    : 'b-fa b-fa-mouse-pointer'
        }]
    },

Note, suspendRefresh is needed when restore scroll position to avoid flickering: https://github.com/bryntum/support/issues/2122

matsbryntse commented 7 months ago

not reproducible