Premium support for our pure JavaScript UI components


Post by david10sing »

Hi

We are using a custom editor form for tasks in gantt and we show a grid to add and delete predecessors and successors.

The grid have combo widget with a store to populate the available records.

useEffect(() => {
    /** Remove the record itself from a list of available tasks */
    let cleanAvailableTasks = currentTask.taskStore.records.filter((record) => {
      return record.id !== currentTask.id;
    });

/** Remove the parent task from the list of available tasks */
if (currentTask.parentId) {
  cleanAvailableTasks = cleanAvailableTasks.filter((record) => {
    return record.id !== currentTask.parentId;
  });
}

/** Remove the list of children from available tasks */
if (currentTask.allChildren.length) {
  const allChildrenIds = currentTask.allChildren.map((record) => record.id);
  cleanAvailableTasks = cleanAvailableTasks.filter((record) => {
    return !allChildrenIds.includes(record.id);
  });
}

/** Remove the existing predecessors from list of available tasks */
const predecessorTaskIds = currentTask.predecessorTasks.map(
  (predecessorTask) => predecessorTask.id
);

const cleanAvailablePredecessorTasks = cleanAvailableTasks.filter(
  (cleanAvailableTask) =>
    !predecessorTaskIds.includes(cleanAvailableTask.id)
);

/** Remove the existing successors from list of available tasks */
const successorTaskIds = currentTask.successorTasks.map(
  (successorTask) => successorTask.id
);

const cleanAvailableSuccessorTasks = cleanAvailableTasks.filter(
  (cleanAvailableTask) => !successorTaskIds.includes(cleanAvailableTask.id)
);

availablePredecessorTasksStore.add(cleanAvailablePredecessorTasks);
availableSuccessorTasksStore.add(cleanAvailableSuccessorTasks);
predecessorsStore.add(currentTask.predecessors);
successorsStore.add(currentTask.successors);
  }, [currentTask.id]);

When we add to the availablePredecessorTasksStore, I get an error with parent tasks

Error: Unknown identifier ClassDefEx-1567962.$.effectiveCalendar

My question is are parent task and normal task different Classes? Why would it throw this error when trying to add tasks to the store of the combo box? Any insights would be appreciated thank you.

Also is there like a predecessor table widget that we could use in some custom task editor?


Post by alex.l »

Really hard to say by the code snippets. Could you please attach a runnable test case.

My question is are parent task and normal task different Classes? 

No, they are the same.

We have https://bryntum.com/docs/gantt/api/SchedulerPro/widget/taskeditor/PredecessorsTab
and https://bryntum.com/docs/gantt/api/SchedulerPro/widget/taskeditor/SuccessorsTab that allow to manage it.

Why can't you use them?

All the best,
Alex


Post by david10sing »

Thank you @Alex.

How do I pass the dependency store to the PredecessorsTab and also how do I set that it needs to look for predecessors or successors for a selected task?

I don't think PredecessorsTab has been built to accept these but I might be wrong.


Post by david10sing »

Thank you @Alex.

How do I pass the dependency store to the PredecessorsTab and also how do I set that it needs to look for predecessors or successors for a selected task?

I don't think PredecessorsTab has been built to accept these but I might be wrong.


Post by alex.l »

Actually yes, your right, it's designed to use with our internal TaskEditor...
There is a hook in our TaskEditor that calls internal loadEvent(taskRecord) method for every tab of the editor. This tab also has this method that will loads the data into the grid. You should call it manually in your case. Also TaskEditor should have project property that points on gantt's project. It also used by that tab.

This is not trivial task, our DependencyTab class has 500+ lines of the code. So better if you try it yourself and if no luck, we can try to fix the problem in your version. But we have to see a runnable test case to reproduce it and help you.

All the best,
Alex


Post by david10sing »

Hi Alex,

Thank you for your reply.

I've got a workaround. I transformed the data and it was not throwing errors anymore... I think task gantt records could not be added to a new store...


Post by alex.l »

Great to hear! Good luck!

All the best,
Alex


Post Reply