Blazor 在 FluentButton onClick 事件上设置参数

问题描述 投票:0回答:1

我尝试在 FluentButton Naviate 方法上设置 Id 参数,但当前上下文中不存在该引用。我是 C# 新手,花了几个小时在这上面,但没有成功。

数据填充网格很好,只是在 onClick 事件上设置参数,这就是问题所在。

我确实尝试将 Items 调整为 AsEnumerable,这修复了单击时的错误,但在 DataGrid 上创建了一个新错误。看最后一张截图

     <FluentDataGrid Items="@sccRequests" Pagination="@pagination">
  <PropertyColumn Property="@(p => p.R_id)" Sortable="true" />
  <PropertyColumn Property="@(p => p.frmwhen)" Format="yyyy-MM-dd" Sortable="true" />
  <PropertyColumn Property="@(p => p.SKU)" Sortable="true" />
  <PropertyColumn Property="@(p => p.related)"  Sortable="true" />
  <PropertyColumn Property="@(p => p.status)" Sortable="true" />
  <TemplateColumn Title="Actions" Align="@Align.End">
           <FluentButton IconEnd="@(new Icons.Regular.Size16.Edit())" @onclick="@(e => Navigate(R_id))" />
      </TemplateColumn>
  

代码:

    public IQueryable<RequestModel>? sccRequests { get; set; }


public async Task RefreshReadData()
{
   sccName = userModel?.userEmail;
   sccRequests = null;
   sccRequests = (await sql.GetRequestsByScc(sccName)).AsQueryable();
    
}

c# parameters onclick blazor fluent-ui
1个回答
0
投票

模板列是一个“模板化组件”

在里面您可以使用

context.
访问该项目。

<FluentButton @onclick="() => Navigate(context.R_Id)" ... />
© www.soinside.com 2019 - 2024. All rights reserved.