[英]Is there a way to create an onClick event to a button within a sync fusion data grid?
I have the following code block in a blazor winform and i'm trying to add a button with an on click event to the id field to edit that row's data in a new form but after scouring documentation I cannot find a way to do this that isn't just changing the fields in the table directly.我在 blazor winform 中有以下代码块,我正在尝试将带有单击事件的按钮添加到 id 字段以以新形式编辑该行的数据但是在搜索文档后我找不到执行此操作的方法不只是直接更改表中的字段。
<SfGrid DataSource="@Customers" RowHeight="20" AllowPaging="true" AllowSorting="true" AllowFiltering="true">
<GridPageSettings PageSize="50"></GridPageSettings>
<GridColumns>
<GridColumn Field=@nameof(Customer.Id) HeaderText="Id" Width="120"></GridColumn>
<GridColumn Field=@nameof(Customer.Name) HeaderText="Name" Width="120"></GridColumn>
<GridColumn Field=@nameof(Customer.Email) HeaderText="Email" Width="120"></GridColumn>
<GridColumn Field=@nameof(Customer.Password) HeaderText="Password" Width="120"</GridColumn>
</GridColumns>
</SfGrid>
I have only tried to accomplish this by creating an onclick event as you would in a traditional html table but I don't believe this can be accomplished within a data grid.我只是尝试通过创建一个 onclick 事件来完成此操作,就像您在传统的 html 表中所做的那样,但我认为这不能在数据网格中完成。
Using Template
you can mainly fully customize the content of a GridColumn
:使用
Template
您可以主要完全自定义GridColumn
的内容:
...
<GridColumn HeaderText="Actions" TextAlign="TextAlign.Center" Width="120">
<Template>
@{
Customer customer = (context as Customer);
<button @onclick="() => OpenEditCustomerForm(customer)">Edit</button>
}
</Template>
</GridColumn>
...
As per your needs, I suggest using the grid column's column template feature, which allows you to customize your needs.根据您的需要,我建议使用网格列的列模板功能,它允许您自定义您的需求。 Please refer to the UG documentation mentioned below for your reference.
请参考下面提到的UG文档供您参考。
Documentation: https://blazor.syncfusion.com/documentation/datagrid/column-template文档: https://blazor.syncfusion.com/documentation/datagrid/column-template
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.