Yeah but I am using two chained Stores, one for each resource type, based in the Master Store. When I a filter to this store one of the chained stores is empty. Is there any way to just hide the ui of the resources?
Support Forum
I think I am already doing that. Let's take the example from this thread: viewtopic.php?p=81692#p81692 :
What I want is to hide some resources in the scheduler entirely, not just group them (as shown in the image).
I am using the stores similar to the example:
const resourceStore = new ResourceStore({
data : resources
});
const machineStore = resourceStore.makeChained(
record => !record.isSpecialRow && record.type === 'machines',
null,
{
// Need to show all records in the combo. Required in case resource store is a tree.
excludeCollapsedRecords : false
}
);
const operatorStore = resourceStore.makeChained(
record => !record.isSpecialRow && record.type === 'operators',
null,
{
// Need to show all records in the combo. Required in case resource store is a tree.
excludeCollapsedRecords : false
}
);
const scheduler = new Scheduler({
...
resourceStore,
...
})
As far as I'm aware to hide the resources, and for example show only the operators in the scheduler, I have to filter the resourceStore:
resourceStore.filter(r => r.type == "operators");
But because machineStore is a chained store based on the resourceStore, it is now empty, because all machines get filtered out in the resources store and I can longer assign them to my events..
I hope that clarifies my problem. Thanks for your support!
- Attachments
-
- Снимок экрана 2021-01-20 в 12.55.57.png (265.72 KiB) Viewed 630 times
Hi applysia,
In your example,resourceStore
is a master store for two others. If you filter it, the result applies on chained stores.
You need to filter a chained store, not a master one. If you used resourceStore
in your scheduler and wants to filter it and don't apply the result to chained instances, I assume you have to create one more chained store to use it in your scheduler and filter that one.
All the best,
Alex
All the best,
Alex
Hi Alex,
I think I missed to provide some important information. I'm actually using the CrudManger as follows:
const resourceStore = new ResourceStore();
const machineStore = resourceStore.makeChained(
record => !record.isSpecialRow && record.type === 'machines',
null,
{
// Need to show all records in the combo. Required in case resource store is a tree.
excludeCollapsedRecords : false
}
);
const operatorStore = resourceStore.makeChained(
record => !record.isSpecialRow && record.type === 'operators',
null,
{
// Need to show all records in the combo. Required in case resource store is a tree.
excludeCollapsedRecords : false
}
);
const scheduler = new Scheduler({
...
crudManager: {
autoLoad: true,
autoSync: true,
resourceStore,
...
}
})
I have to pass the master store to scheduler initially to get the data into the store. So I can not use a chained store here, because the master store it would be empty. But later I can not filter the resource store of the scheduler with:
scheduler.resourceStore.filter((resource) => resource.type === 'observer');
Because this store is the master store and would result in an empty chained store.
I think it's not a problem, that all records of both types are in this store I just want to hide one type visually in the scheduler.
But later I can not filter the resource store of the scheduler Because this store is the master store and would result in an empty chained store.
Master and chained store have independent filters. Please refer to this demo: https://bryntum.com/examples/grid/basic/
> chained = grid.store.chain(r => r.age < 30)
Store {added: StoreBag, removed: StoreBag, modified: StoreBag, idRegister: {…}, internalIdRegister: {…}, …}
> chained.map(r => r.age)
(12) [14, 18, 14, 16, 15, 14, 15, 16, 29, 24, 19, 11]
> grid.store.filter(r => r.age > 20)
undefined
> chained.map(r => r.age)
(12) [14, 18, 14, 16, 15, 14, 15, 16, 29, 24, 19, 11]