Reputation: 33
i am using radzen for blazor, how can i get the TItem="MailTemplate" passed in the yes/no dialog service ?
<RadzenGrid @ref="m_gridTemplates" Data="@m_emailTemplates" TItem="MailTemplate" AllowScrolling="true" AllowPaging="true" PageSize="10" EditMode="DataGridEditMode.Single">
<RadzenButton ButtonStyle="ButtonStyle.Danger" Icon="close" Size="ButtonSize.Small" Click=@(args => DialogService.Confirm("Are you sure?", "Delete Template (" +mailTemplate.FileName + ")", new ConfirmOptions() { OkButtonText = "Yes", CancelButtonText = "No" })) MouseEnter="@(args => ShowTooltip(args, new TooltipOptions(){ Position = TooltipPosition.Top ,Text = "Delete Template"}))"/>
Upvotes: 3
Views: 5979
Reputation: 651
I know this is a bit late, but I just had the same question, and was helped by this answer in the Radzen forums: https://forum.radzen.com/t/confirmation-modal-dialog/4069/8
The basic idea is that instead of directly calling the DialogService.Confirm
method, you call it from your own method which you have passed whatever you need to.
In case of link rot:
<RadzenButton ButtonStyle="ButtonStyle.Danger" Icon="delete" Text="Delete" Click="@(args => ConfirmDelete(yourObject.Id))" @onclick:stopPropagation="true"></RadzenButton>
public async Task ConfirmDelete(int id)
{
var confirmationResult = await this.DialogService.Confirm("Are you sure?", "Dialog Title", new ConfirmOptions { OkButtonText = "Yes", CancelButtonText = "No" });
if (confirmationResult == true)
{
//Delete logic for id
}
}
Upvotes: 8
Reputation: 1
TItem="MailTemplate" looks like a type, not like a value. Note, that i am using RadzenDataGrid, not RadzenGrid. Here is a sample of my code, modifying Type "Order", with value "order", and from a data source "Orders"
<RadzenGrid Data="@Orders" TItem="Order" AllowScrolling="true" AllowPaging="true" PageSize="10" EditMode="DataGridEditMode.Single">
<Columns>
<RadzenDataGridColumn TItem="Order" Context="ord" Filterable="false" Sortable="false" TextAlign="TextAlign.Center" Width="130px" Title="Remove order reference">
<Template Context="ord">
<RadzenButton ButtonStyle="ButtonStyle.Danger" Icon="assignment_turned_in" Size="ButtonSize.Small" Click="@(args => editOrder(ord))"></RadzenButton>
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenGrid>
@Code{
async Task editOrder(Order order)
{
order = null;
}
}
Upvotes: 0