|
[Index.razor]
// Render Dialog
<SfDialog ID="DialogContainer" @ref="Dialog" Width="700px" IsModal="true" Header="Add Custom Dialog" @bind-Visible="@IsVisible">
<DialogTemplates>
<Content>
This is Custom dialog.
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Cancel" OnClick="@CloseDialog" />
</DialogButtons>
<DialogAnimationSettings Effect="DialogEffect.None"/>
</SfDialog>
// Render Gantt
<SfGantt ID="GanttContainer" @ref="Gantt" DataSource="@TaskCollection"
……./////
<GanttEvents OnToolbarClick="onToolbarClick" TValue="TaskData"></GanttEvents>
</SfGantt>
private bool IsVisible { get; set; } = false;
// Triggers on toolbar click actions
public void onToolbarClick(ClickEventArgs args)
{
if (args.Item.Text == "Add" || args.Item.Text == "Edit")
{
args.Cancel = true; // Cancel the default dialog
}
RenderDialog();
}
public void RenderDialog()
{
this.Dialog.Show(); // Render custom dialog
}
private void CloseDialog()
{
this.Dialog.Hide(); // Hide custom dialog
} |
|
<SfGantt ID="GanttContainer" @ref="Gantt" DataSource="@TaskCollection" Height="450px"
…////
<GanttEvents OnActionBegin="OnActionBegin" TValue="TaskData"></GanttEvents>
</SfGantt>
@code{
public void OnActionBegin(ActionBeginArgs<TaskData> args)
{
if (args.RequestType == "beforeOpenEditDialog")
{
args.Cancel = true;
RenderDialog();
}
}
} |