Our state of the art Gantt chart


Post by casman.manzano »

How would I go about changing what appears in the right click menu depending on what record the user is right clicking on, is there a handler for when user right clicks? so that I can show/hide options depending on the record?


Post by mats »


Post by casman.manzano »

ok so for example...

 features: {
    taskMenu: {
      processItems({ items, taskRecord }) {
        // Not possible to edit or delete tasks if there is no rights for it
        console.log(taskRecord);
      },
      items: {
        // Custom reference to the new menu item
        moveForward: {
          text: "Move 1 hour ahead",
          weight: 90, // Add the item to the top
          onItem: ({ taskRecord }) => {
            taskRecord.shift(1, "hour");
          },
        },
      },
    },

if I wanted the "moveForward" item to appear in the menu depending on "taskRecord" hypothetical property (here let's pretend it's "show"), which holds a boolean. how would I make that happen?


Post by mats »

Read here to learn the items available: https://bryntum.com/docs/gantt/#Gantt/feature/TaskMenu

It's explained there as you can read:

const gantt = new Gantt({
    features : {
        taskMenu : {
            // Extra items for all events
            items : {
                flagTask : {
                    text : 'Extra',
                    icon : 'b-fa b-fa-fw b-fa-flag',
                    onItem({taskRecord}) {
                        taskRecord.flagged = true;
                    }
                }
            },
             processItems({ items, taskRecord }) {
                 // Do not show allow flagTask for secret tasks
                 items.flagTask.disabled = taskRecord.type === 'secret';
            }
        }
    }
});

and https://bryntum.com/docs/gantt/#Grid/feature/CellMenu for cells in the left tree.


Post Reply