我是Blazor和Blazorise...and的新手,在研究这个组件时,我似乎找不到任何关于如何在Blazorise DataGrid的EditTemplate中绑定TextEdit中的变量的材料。
在我的Blazorise DataGrid中,我有一个DataColumn (参见下面的代码):
<DataGridColumn
Caption="Description"
Editable="true"
TItem="ProductVo"
Field="@nameof(ProductVo.Description)">
<DisplayTemplate>
@($"{(context as ProductVo)?.Description}")
</DisplayTemplate>
<EditTemplate>
<Validation UsePattern="true">
<TextEdit @bind-Text="context.CellValue" Text="@((string)context.CellValue)" Pattern="^.{3,200}$">
<Feedback>
<ValidationError>This field must be between 3 and 200 characters long.</ValidationError>
</Feedback>
</TextEdit>
</Validation>
</EditTemplate>
</DataGridColumn>在我的<TextEdit>中,我可以使用以下代码在编辑时显示该值:
Text="@((string)context.CellValue)"但是它不能保存,因为我不能使用@bind-Text="context.CellValue"绑定context.CellValue。
请帮助我学习如何使用Blazorise DataGrid,谢谢!
发布于 2021-02-10 12:46:38
您错过了负责更新context上的文本的TextChanged事件。这应该是可行的:
<TextEdit Text="@((string)context.CellValue)" TextChanged="@(v => ( (CellEditContext)context ).CellValue = v)" Pattern="^.{3,200}$">https://stackoverflow.com/questions/66130953
复制相似问题