Le TOP 3 des diagrammes de Gantt JavaScript. Découvrez leurs caractéristiques, avantages et inconvénients pour choisir le meilleur outil pour votre projet.
ScheduleJS allows you to build complex drag-and-drop interactions, including side effects. This article will discuss how to build advanced drag-and-drop operations using the framework customization APIs.
ScheduleJS supports drag-and-drop by default. The base behavior is the following:
To edit this behavior, a set of methods is made available to the developer.
The method to edit the drag-and-drop operation mode is:
graphics.setEditModeCallback(Activity, Layout, callback)
It will let you set which drag-and-drop operation you want to use for a specific Activity et un projet LayoutType. You can build logic based on the activity data and from the event that its callback receives.
Let’s see how we can implement this with the following example:
// Register a new edit mode callback for MyActivity in a GanttLayout
graphics.setEditModeCallback(MyActivity, GanttLayout, myEditModeCallback);
// This callback will disallow drag-and-drop if no modifier key is pressed
const myEditModeCallback = (event: EditModeCallbackParameter) => {
if (event.getPointerEvent().shiftKey) {
return EditModeEnum.DRAGGING;
}
if (event.getPointerEvent().ctrlKey) {
return EditModeEnum.DRAGGING_HORIZONTAL;
}
return EditModeEnum.NONE;
};
In this example, the myEditModeCallback
function will receive an event
parameter of type EditModeCallbackParameter holding the ActivityBounds (which in turn holds an ActivityRef) and the native JavaScript PointerEvent. It will trigger whenever the user hovers any activity of type MyActivity in a GanttLayout context.
The return value of this callback has to be of type EditModeEnum. The EditModeEnum holds the following drag-and-drop possibilities:
// The EditModeEnum
export declare enum EditModeEnum {
AGENDA_ASSIGNING = "AGENDA_ASSIGNING",
AGENDA_DRAGGING = "AGENDA_DRAGGING",
AGENDA_END_TIME_CHANGE = "AGENDA_END_TIME_CHANGE",
AGENDA_START_TIME_CHANGE = "AGENDA_START_TIME_CHANGE",
CHART_VALUE_CHANGE = "CHART_VALUE_CHANGE",
CHART_VALUE_HIGH_CHANGE = "CHART_VALUE_HIGH_CHANGE",
CHART_VALUE_LOW_CHANGE = "CHART_VALUE_LOW_CHANGE",
DELETING = "DELETING",
DRAGGING = "DRAGGING",
DRAGGING_HORIZONTAL = "DRAGGING_HORIZONTAL",
DRAGGING_VERTICAL = "DRAGGING_VERTICAL",
END_TIME_CHANGE = "END_TIME_CHANGE",
NONE = "NONE",
PERCENTAGE_COMPLETE_CHANGE = "PERCENTAGE_COMPLETE_CHANGE",
START_TIME_CHANGE = "START_TIME_CHANGE"
}
For example, to disallow a drag-and-drop operation, you can build a callback that evaluates the desired context and returns the EditModeEnum.NONE
value.
The following example shows a setup where the return value of this callback is EditModeEnum.DRAGGING_VERTICAL
Now that the drag-and-drop mode is set according to your needs, you might want to edit what happens when the user is dragging the Activity. To do so, ScheduleJS provides a set of methods to monitor and affect your application’s state at runtime:
graphics.onActivityDragStart((event: ActivityEvent) => callback)
will trigger a callback whenever a drag-and-drop operation startsgraphics.onActivityDragOngoing((event: ActivityEvent) => callback)
will trigger a callback whenever a drag-and-drop-operation is ongoinggraphics.onActivityDragFinished((event: ActivityEvent) => callback)
will trigger a callback whenever a drag-and-drop operation is finishedLe ActivityEvent holds an ActivityRef to get activity-related information, EventType information, the old TimeInterval before the operation, and extra specific information like the old and new Row in case you are in a vertical drag-and-drop context and the old value in case of a ChartLayout.
In addition to these three, the same sort of methods exist for:
The following example shows a use-case where we had to enforce activities order when using the drag-and-drop feature:
Le TOP 3 des diagrammes de Gantt JavaScript. Découvrez leurs caractéristiques, avantages et inconvénients pour choisir le meilleur outil pour votre projet.
Découvrez comment ScheduleJS s'est intégré en toute transparence à Selligent CRM, améliorant ainsi l'efficacité de la planification pour les consultants d'une grande marque de produits de beauté.
Cet article présente l'intégration d'un composant ScheduleJS dans un tableau Ag-Grid externe, afin de démontrer la flexibilité de ScheduleJS.
Comment synchroniser plusieurs graphiques ? Apprenez à réutiliser votre ligne de temps ScheduleJS dans plusieurs graphiques afin de les synchroniser.
Comment construire un menu contextuel interactif ? Une plongée en profondeur dans la gestion des événements ScheduleJS et les pratiques recommandées pour construire votre propre menu contextuel.
Cet article montre comment mettre en œuvre un rendu dynamique en fonction du niveau de zoom actuel des graphiques.
Cet article propose une mise en œuvre pas à pas d'un mécanisme d'animation utilisant l'API JavaScript Date pour vos activités.
Cet article traite d'une implémentation de websocket avec un rendu de données en temps réel en utilisant le moteur de dessin ScheduleJS.
Cet article présente l'implémentation d'une colonne d'information personnalisée en utilisant un composant AG Grid à la place du composant par défaut.
Cet article vous montrera comment a été construite l'architecture de l'arbre de Gantt parent-enfant dans le ScheduleJS Viewer.