This example demonstrates how display a custom "Task details" dialog instead of the default dialog.
- Add a popup edit form in your application.
@(Html.DevExtreme().Popup()
.ID("taskDetailsPopup").MaxWidth(800).MaxHeight(500).Title("Task Details")
.ContentTemplate(new TemplateName("customPopupContentTemplate"))
.ToolbarItems(items => {
items.Add()
.Widget(editor => editor.Button()
.Text("Confirm")
.Type(ButtonType.Success)
.OnClick("onConfirmClick")
)
.Location(ToolbarItemLocation.After)
.Toolbar(Toolbar.Bottom);
items.Add()
.Widget(editor => editor.Button()
.Text("Cancel")
.Type(ButtonType.Success)
.OnClick("onCancelClick")
)
.Location(ToolbarItemLocation.After)
.Toolbar(Toolbar.Bottom);
})
.OnInitialized("onPopupInitialized").OnShown("onShown")
) function onPopupInitialized(e) {
popup = e.component;
}- Handle the taskEditDialogShowing event to prevent the default dialog and display your custom dialog instead. Bind the form in the popup control to processed task data.
function onTaskEditDialogShowing(e) {
e.cancel = true;
showTaskDetails(gantt.getTaskData(e.key))
}
function showTaskDetails(data) {
popup.option("visible", true);
if (form)
form.option('formData', data);
}- Call the updateTask and assignResourceToTask/unassignResourceFromTask methods to update Gantt data.
function onConfirmClick(e) {
let result = form.validate();
if (result.isValid) {
var data = form.option("formData");
gantt.updateTask(data.Key, data);
gantt.unassignAllResourcesFromTask(data.Key);
data.Resources.forEach(r => gantt.assignResourceToTask(r, data.Key));
popup.hide();
}
}- Angular
- React
- Vue
- jQuery
- ASP.NET Core
- Gantt - Getting Started
- Gantt - taskEditDialogShowing Event
- Gantt - updateTask Method
- Gantt - assignResourceToTask Method
- Gantt - unassignResourceFromTask Method
(you will be redirected to DevExpress.com to submit your response)
