Our pure JavaScript Scheduler component


Post by shawnwong »

Hi All,

Anyone have experience with filtering the resource list inside TaskEdit?

I only want to allow assignment to a resource if "skill" column matches.

 listeners: {
         beforeTaskEditShow({ source,taskEdit, editor, taskRecord,renderData }) {
          
const reqSkills = taskRecord.reqSkills; const resourceList = editor.widgetMap.generalTab.items[2].store.filter('skills', reqSkills); }, .....

it works , but when i click on X or Cancel button, my resource list will delete the resource
Im using SchedulerPro

thank you
Shawn


Post by alex.l »

Hi Shawn,

Could you please provide a test case to reproduce it? We need more context. The only thing that I have in my mind now - you apply filter for main resourceStore in your code, so resource has not been deleted but filtered. I cannot be sure before debug your code.
If I am correct, the solution will be to use chained store for resourceList and not filter the initial store.
https://bryntum.com/docs/scheduler-pro/api/Core/data/mixin/StoreChained

All the best,
Alex


Post by shawnwong »

Hi Alex,

thank you for your reply.

https://drive.google.com/file/d/1ri5cdWsjf5sXbDJ-4a2b3VrU3WhhxUy8/view?usp=sharing

can help me take a look what i did wrong?

thanks
Shawn

Attachments
validation.zip
(378.01 KiB) Downloaded 50 times

Post by alex.l »

Checking you code and cannot understand what exactly are you trying to achieve.
I see find method now instead of filter, so I am not sure what's your goal.

From my comment above. resourceField uses original resourceStore by default. If you apply filter on combo's store, it will filter resources in your scheduler as well. To see resourceField with filtered set of resources, you need to use chained instance of resourceStore and apply filter on that instance instead.

            const reqSkills = taskRecord.reqSkills; // just copied from your code
            const resourcesField = editor.widgetMap.resourcesField; // easier to get resourcesField by it's reference name, instead of index

        const resourceList = resourcesField.store.chain(); // create chained store
        resourcesField.store = resourceList; // apply new instance of store to combo
        resourceList.filter('skills', reqSkills); // filter chained store

All the best,
Alex


Post by shawnwong »

Hi Alex,

Thanks for the reply.

I got the desire outcome.

thanks!
Shawn

alex.l wrote: Mon May 23, 2022 9:23 am

Checking you code and cannot understand what exactly are you trying to achieve.
I see find method now instead of filter, so I am not sure what's your goal.

From my comment above. resourceField uses original resourceStore by default. If you apply filter on combo's store, it will filter resources in your scheduler as well. To see resourceField with filtered set of resources, you need to use chained instance of resourceStore and apply filter on that instance instead.

            const reqSkills = taskRecord.reqSkills; // just copied from your code
            const resourcesField = editor.widgetMap.resourcesField; // easier to get resourcesField by it's reference name, instead of index

        const resourceList = resourcesField.store.chain(); // create chained store
        resourcesField.store = resourceList; // apply new instance of store to combo
        resourceList.filter('skills', reqSkills); // filter chained store

Post Reply