My Blazor app has a grid with a custom toolbar with "Create" and "Edit" actions, like so...
I have hooked up the "Create New" action so that I can call a reusable dialog box to create a record.
However, I cannot figure out how to pass the unique key of the edited record so that I can use the same reusable dialog box to edit a record.
I have attached the files in question.
In the My_Templates.razor file, I check to see if we have hit the Add or the Edit button and take the appropriate action. But in the edit action I do not know how to pass the unique key of the selected record. That is the first problem.
public async Task OnClicked(Syncfusion.Blazor.Navigations.ClickEventArgs Args)
{ if (Args.Item.Id == "Add") //Call Dialog Box Here
dialog.Title = "This is the Add Title";
dialog.Text = "This is the add text";
dialog.OpenDialog();
if (Args.Item.Id == "Edit")
//Call Dialog Box Here
dialog.Title = "This is the Edited Title";
dialog.Text = "This is the edited text";
dialog.templateID = 2; //WHAT DO I PUT HERE
dialog.OpenDialog(); }
The second problem is that in my ReusableDialog box I am not sure how to retrieve the record. Or perhaps I should pass the entire record from the view above?
Any assistance would be gr
|
public async Task OnClicked(Syncfusion.Blazor.Navigations.ClickEventArgs Args)
{
if (Args.Item.Id == "Add")
{
//to prevent the default action
Args.Cancel = true;
//Call Dialog Box Here
dialog.Title = "This is the Add Title";
dialog.Text = "This is the add text";
dialog.employee = new Order();
dialog.OpenDialog();
}
if (Args.Item.Id == "Edit")
{
//to prevent the default action
Args.Cancel = true;
var selected = await Grid.GetSelectedRecordsAsync();
if (selected.Count > 0)
{
//Call Dialog Box Here
dialog.Title = "This is the Edited Title";
dialog.Text = "This is the edited text";
dialog.employee = selected[0]; //WHAT DO I PUT HERE
dialog.OpenDialog();
}
else
{
//show custom dialog to select a record.
}
}
|
Thank you very much, this worked perfect!