<SfDialog ID="DialogContainer" @ref="Dialog" Width="400px" IsModal="true" Header="Gantt Custom Dialog" @bind-Visible="@IsVisible">
<DialogTemplates>
<Content>
<label>ID</label><br />
<SfTextBox ID="InputIdContainer" @ref="InputId" Placeholder="Id" Width="300px" Value="@Id" Enabled="false"></SfTextBox><br/>
<label>Task Name</label><br />
<SfTextBox ID="InputNameContainer" @ref="InputName" Placeholder="TaskName" Width="300px" Value="@Name"></SfTextBox><br />
<label>Progress</label><br />
<SfTextBox ID="InputProgressContainer" @ref="InputProgress" Placeholder="Progress" Width="300px" Value="@Progress"></SfTextBox><br />
<label>Start Date</label><br />
<SfTextBox ID="InputsDateContainer" @ref="InputsDate" Placeholder="StartDate" Width="300px" ></SfTextBox><br />
<label>End Date</label><br />
<SfTextBox ID="InputeDateContainer" @ref="InputeDate" Placeholder="EndDate" Width="300px" ></SfTextBox><br />
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Ok" OnClick="@OkDialog"></DialogButton>
<DialogButton Content="Cancel" OnClick="@CloseDialog" />
</DialogButtons>
<DialogAnimationSettings Effect="DialogEffect.None" />
</SfDialog>
<SfGantt @ref="Gantt" ID="GanttExport">
//...
</SfGantt>
//...
@code {
public string Name { get; set; }
public string Id { get; set; }
public string Progress { get; set; }
public DateTime? Sdate { get; set; }
public DateTime? Edate { get; set; }
private bool IsVisible { get; set; } = false;
public SfGantt<Table> Gantt;
public SfDialog Dialog;
public SfTextBox InputName;
public SfTextBox InputProgress;
public SfTextBox InputId;
public SfTextBox InputsDate;
public SfTextBox InputeDate;
public void actionBegin(ActionBeginArgs<Table> args)
{
if (args.RequestType == "beforeOpenEditDialog")
{
//Restricting the opening of default dialog
args.Cancel = true;
RenderDialog(args.RowData.TaskData);
}
}
//Method to render the custom dilaog
public void RenderDialog(Table data)
{
Id = data.Id.ToString();
Name = data.Name;
Progress = data.Progress;
Sdate = data.Sdate;
Edate = data.Edate;
this.Dialog.Show();
}
private void CloseDialog()
{
this.Dialog.Hide();
}
private void OkDialog()
{
// Updating the record using UpdateRecordByID method
this.Gantt.UpdateRecordByID(new Table()
{
Id = Convert.ToInt16(this.InputId.Value),
Name = this.InputName.Value,
Progress = this.InputProgress.Value,
Sdate = Convert.ToDateTime(this.InputsDate.Value),
Edate = Convert.ToDateTime(this.InputeDate.Value),
});
this.Dialog.Hide();
}
}
//... |
private void OkDialog()
{
var editedData = new Table()
{
Id = Convert.ToInt16(this.InputId.Value),
Name = this.InputName.Value,
Progress = this.InputProgress.Value,
Sdate = Convert.ToDateTime(this.InputsDate.Value),
Edate = Convert.ToDateTime(this.InputeDate.Value),
Predecessor = this.InputDep.Value,
ParentId = this.InputPar.Value
};
//editedData containing the all fields of the Table before passing it to the UpdateRecordByID method
this.Gantt.UpdateRecordByID(editedData);
this.Dialog.Hide();
} |