Our state of the art Gantt chart


Post by rayudu.pasumarthy »

Hi,

Is it possible for the ResourceColumnEditor to not show some resources from resourceStore based on a condition?

For example, if resource.name == 'Celia', don't show/disable her pick in the AssignmentField editor

Currently, we are using the following code:

{ type : 'resourceassignment', cls: 'resourcesCol', width : 100, showAvatars : false , enableHeaderContextMenu: false,
            editor : {
                chipView : {
                    itemTpl : assignment => assignment.resource.name
                },
                picker: {
                    unitsColumn : {
                        hidden : true
                    }
                },
            },
            itemTpl : assignment => assignment.resource.name
        },

Any thoughts / suggestions?

Thanks,
Rayudu.


Post by mats »

It sure can, the editor is a picker field showing a grid. A grid is powered by a data store which is filterable. Please see the editor at https://bryntum.com/examples/gantt/advanced/ it already has a filter bar enabled.

Docs: https://bryntum.com/docs/gantt/api/Core/data/Store#function-filterBy

Attachments
Screenshot 2021-11-14 at 11.13.36.png
Screenshot 2021-11-14 at 11.13.36.png (116.86 KiB) Viewed 851 times

Post by rayudu.pasumarthy »

Thanks Mat, it is working with the follow code

{ type : 'resourceassignment', cls: 'resourcesCol', width : 100, showAvatars : false , enableHeaderContextMenu: false,
            editor : {
                chipView : {
                    itemTpl : assignment => assignment.resource.name
                },
                picker: {
                    unitsColumn : {
                        hidden : true
                    },
                    store: {
                        filters: [{
                            filterBy: (record) => {
                                return record.data.resource.name != 'Celia'
                            }
                        }]
                    }
                },
            },
            itemTpl : assignment => assignment.resource.name
        },

Post by rayudu.pasumarthy »

Hi,

Adding the above code nullifies the selection.

selection_removed.png
selection_removed.png (9.8 KiB) Viewed 842 times

Is it possible to apply the filterBy function along with maintaining the right selection?

Thanks,
Rayudu.


Post by Maxim Gorkovsky »

Reproduced, ticket opened here: https://github.com/bryntum/support/issues/3729 Thank you for report.


Post by rayudu.pasumarthy »

Hi Maxim,

Thanks for the ticket. Any info on when the issue would be resolved? Or is there a temporary alternative to re-check for selections?

Thanks,
Rayudu.


Post by Maxim Gorkovsky »

Hello.
You can try this workaround using https://bryntum.com/docs/scheduler/api/Grid/view/GridBase#event-startCellEdit:

new Gantt({
  listeners : {
        // add condition to make sure you're editing target column
        startCellEdit({ editorContext : { value, editor } }) {
            const grid = editor.inputField.picker;
            const resourceIds = value.map(v => v.resourceId);

            grid.deselectAll();
            const selection = grid.store.query(r => resourceIds.includes(r.resourceId));
            grid.selectRows(selection, true);
        }
    }
})

There is no estimation on the ticket yet, I'm afraid. You can subscribe to the ticket on github to stay it touch


Post by Maxim Gorkovsky »

Speaking of ticket, it should be addressed within next 3-6 weeks.


Post by rayudu.pasumarthy »

Thanks Maxim, the workaround is working great!

Thanks,
Rayudu.


Post by Animal »

In the next version, this will work out of the box.

You will have to configure your filter with the new internal property so that it remains attached to the store when the field clears its filters on hide.

                picker: {
                    unitsColumn : {
                        hidden : true
                    },
                    store: {
                        filters: [{
                            filterBy: (record) => {
                                return record.data.resource.name != 'Celia'
                            },
                            internal : true // Fixed part of the Store
                        }]
                    }
                }
Screenshot 2022-08-09 at 15.46.04.png
Screenshot 2022-08-09 at 15.46.04.png (94.17 KiB) Viewed 416 times

Post Reply