Page 1 of 1

Resource filter inside TaskEdit

Posted: Thu May 19, 2022 10:40 am
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


Re: Resource filter inside TaskEdit

Posted: Fri May 20, 2022 7:54 am
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


Re: Resource filter inside TaskEdit

Posted: Sat May 21, 2022 5:13 am
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


Re: Resource filter inside TaskEdit

Posted: Mon May 23, 2022 9:23 am
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

Re: Resource filter inside TaskEdit

Posted: Mon May 23, 2022 12:00 pm
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