Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reapplyFilterOnAdd doesn't work when adding resources before loading #5553

Closed
taauntik opened this issue Nov 9, 2022 · 1 comment
Closed
Assignees
Labels
bug Something isn't working forum Issues from forum large-account Reported by large customer resolved Fixed but not yet released (available in the nightly builds)
Milestone

Comments

@taauntik
Copy link

taauntik commented Nov 9, 2022

Forum post

Hello,

This is the code I have tested on the same basic demo https://bryntum.com/examples/scheduler/basic/

When the last line is commented, all the resources are added, even those with name.length <= 3
I need to manually filter with scheduler.resourceStore.filter(), which I don't understand why since reapplyFilterOnAdd is set to true

import { Scheduler } from '../../build/scheduler.module.js?463310';
import shared from '../_shared/shared.module.js?463310';

//region Data

const
    resources = [
        { id : 'r1', name : 'Mike' },
        { id : 'r2', name : 'Linda' },
        { id : 'r3', name : 'Don' },
        { id : 'r4', name : 'Karen' },
        { id : 'r5', name : 'Doug' },
        { id : 'r6', name : 'Peter' },
        { id : 'r7', name : 'Sam' },
        { id : 'r8', name : 'Melissa' },
        { id : 'r9', name : 'John' },
        { id : 'r10', name : 'Ellen' }
    ],
    events = [
        {
            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'
        },
        {
            id         : 2,
            resourceId : 'r2',
            startDate  : new Date(2017, 0, 1, 12),
            endDate    : new Date(2017, 0, 1, 13, 30),
            name       : 'Drag me',
            iconCls    : 'b-fa b-fa-arrows-alt'
        },
        {
            id           : 3,
            resourceId   : 'r3',
            startDate    : new Date(2017, 0, 1, 14),
            duration     : 2,
            durationUnit : 'h',
            name         : 'Double click me',
            eventColor   : 'purple',
            iconCls      : 'b-fa b-fa-mouse-pointer'
        },
        {
            id         : 4,
            resourceId : 'r4',
            startDate  : new Date(2017, 0, 1, 8),
            endDate    : new Date(2017, 0, 1, 11),
            name       : 'Right click me',
            iconCls    : 'b-fa b-fa-mouse-pointer'
        },
        {
            id         : 5,
            resourceId : 'r5',
            startDate  : new Date(2017, 0, 1, 15),
            endDate    : new Date(2017, 0, 1, 17),
            name       : 'Resize me',
            iconCls    : 'b-fa b-fa-arrows-alt-h'
        },
        {
            id         : 6,
            resourceId : 'r6',
            startDate  : new Date(2017, 0, 1, 16),
            endDate    : new Date(2017, 0, 1, 19),
            name       : 'Important meeting (read-only)',
            iconCls    : 'b-fa b-fa-exclamation-triangle',
            eventColor : 'red',
            readOnly   : true
        },
        {
            id         : 7,
            resourceId : 'r6',
            startDate  : new Date(2017, 0, 1, 6),
            endDate    : new Date(2017, 0, 1, 8),
            name       : 'Sports event',
            iconCls    : 'b-fa b-fa-basketball-ball'
        },
        {
            id         : 8,
            resourceId : 'r7',
            startDate  : new Date(2017, 0, 1, 9),
            endDate    : new Date(2017, 0, 1, 11, 30),
            name       : 'Dad\'s birthday!',
            iconCls    : 'b-fa b-fa-birthday-cake',
            // Custom styling from data
            style      : 'background-color : teal; font-size: 18px',
            // Prevent default styling
            eventStyle : 'none'
        }
    ];

const resourceStore = {
    tree: true,
    transformFlatData: true,
    syncDataOnLoad: false,
    reapplyFilterOnAdd: true,
    reapplyFilterOnUpdate: true,
    filters: [
        { 
           filterBy: (r) => r.name.length > 3
        }
    ]
};

//endregion

const scheduler = new Scheduler({
    appendTo         : 'container',
    resourceStore,
    events           : events,
    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 }
    ]
});
scheduler.resourceStore.add(resources);
// scheduler.resourceStore.filter();
@taauntik taauntik added bug Something isn't working forum Issues from forum large-account Reported by large customer labels Nov 9, 2022
@fanckush
Copy link

The same problem occurs with Scheduler Pro

@matsbryntse matsbryntse self-assigned this Jun 27, 2023
@matsbryntse matsbryntse added ready for review Issue is fixed, the pull request is being reviewed resolved Fixed but not yet released (available in the nightly builds) and removed ready for review Issue is fixed, the pull request is being reviewed labels Jun 27, 2023
@matsbryntse matsbryntse added this to the 5.4.0 milestone Jun 28, 2023
@SergeyMaltsev SergeyMaltsev changed the title reapplyFilterOnAdd doesn't work when adding resources before loading reapplyFilterOnAdd doesn't work when adding resources before loading Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum large-account Reported by large customer resolved Fixed but not yet released (available in the nightly builds)
Projects
None yet
Development

No branches or pull requests

3 participants