Premium support for our pure JavaScript UI components


Post by jsalguero »

Hello, in my example, I have two buttons.
Click me -> to load the initial data
Filter me -> to filter the initial data by only removing some of the initial events.
Click works fine for me as expected. However, the Filter me button does not work as expected and the brintum component is not updated with the events that are filtered.
Could you help me understand why the filter button doesn't work as expected?
By the way, I've noticed that the drag and drop fails and the event that shouldn't paint is blocked, not letting me move or resize it.

simpleeditor.zip
Angula brintum example
(213.17 KiB) Downloaded 45 times

Post by Animal »

Filtering is much much simpler than that.

Just

scheduler.eventStore.filter(event => event.id > 1);

or for generic filtering on any field, an example might be

scheduler.eventStore.filter({
    property : 'id',
    operator : '>',
    value : 1
});

Do not change the full dataset just to filter.


Post by jsalguero »

Hello, thank you very much for your quick response. I understand what you're saying, but I need to do it like in the example I'm proposing, because in a much larger and much more complex project, it's being done that way and making the change you're proposing would be a lot of work. Could you work on my example to try to make it work?
Thank you very much in advance


Post by Animal »

Why are you destroying the Scheduler a lot in your code?

If you want to set the event data, the only one line you have to do is

scheduler.eventStore.data = [...]; // new events

Whatever you do, do not destroy the Scheduler.


Post by jsalguero »

Thanks again for your help.
I need to understand why my example doesn't work.
Please, clould you clarify it?


Post by alex.l »

There are might be many reasons.

  1. For Angular we do not recommend use Scheduler without wrapper. See our demos and guide https://bryntum.com/products/scheduler/docs/guide/Scheduler/integration/angular/guide
  2. You used resourceId together with assignmentStore, but you should use or resourceId or assignmentStore data.
    https://bryntum.com/products/scheduler/docs/api/Scheduler/model/EventModel#field-resourceId
  3. You are destroying and re-creating component on data change, so that might be a race-condition problem.
  4. You created EventModel instance before load it onto store, so resourceId might be cleared because assignment won't be resolved - when no according resource found, assignment cannot be created and resourceId linking will be removed.

All the best,
Alex


Post by jsalguero »

Hi Alex, thanks for your response.
In response to your reply, I would like to tell you the following:
1.- Thanks for the indication. I'm going to try to build another example using the wrapper.
2.- Could you tell me in which line of my attached example I am using the resourceId mode? My approach is using AssignmentStore if I'm not mistaken. Please I need confirmation of this.
3.- The fact of destroying it should be totally freeing the memory of the object and not leaving orphaned data inside the freed variable. However, I'll set it to null beforehand and I understand that this shouldn't be a problem.
4.- This comment does not make sense; it seems to be a standard answer that does not apply to my case. I don't see that I am assigning any resourceId in my code. Please review it again and see if this comment is consistent with my exposed case.


Post by alex.l »

#2 Here

    this.events = [...this.events.filter(x=> x.id>1)];
    //recargo los assignments como en proyecto final
    this.assignments = [];
    this.events.forEach(event =>
        this.assignments.push({
            id       : 'a' + event.id,
            event    : event.id,
            resource : event.resourceId
        })

if you used this.events as data for the scheduler, this means resourceId is filled.
And yes you did.

        this.scheduler.project = new ProjectModel({
            // ...
            eventStore : {
                useRawData : true,
                data       : this.events
            }
        });

No 4
I highlighted possible reasons for your analyse. If you see it's not fit to you, just leave it. It's hard to understand what exactly happening in your code, I see in your code both - resourceId and assignmentStore, as well as I see you created EventModel instance out of store. That's why I mentioned that moment for you to check.

All the best,
Alex


Post Reply