这里是一个TelerikForm, FormItem(1)是一个布尔字段。另一个FormItem(2)应该呈现,这取决于布尔字段(1)。这不适用于TelerikForm,但适用于标准的EditForm。
TelerikForm的解决方案是使用带有TelerikCheckBox的FormItem模板。下面也演示了这一点。
< EditForm模型=“@_data”><标签>条件1 (InputCheckbox):标签><InputCheckbox@bind-Value=“@_data。Value1”/><br/>@如果(_data.Value1) {<标签>结果2标签><InputCheckboxDisplayName=“结果2:@bind-Value=“@_data。Value2”>InputCheckbox>} < / EditForm ><h1>TelerikFormh1><TelerikForm模型=“@_data”><FormItems><FormItemLabelText="条件一(表格项):"场=“@nameof (_data.Value1)”>FormItem><FormItem><模板><标签为=“x”>条件1 (TelerikCheckBox):标签><br/><TelerikCheckBoxId=“x”@bind-Value=“_data。Value1”/>模板>FormItem>@if (_data.Value1) {<FormItemLabelText=“结果2:场=“@nameof (_data.Value2)”>FormItem>}FormItems>TelerikForm>@code{私有ExampleDto _data {get;设置;} =新ExampleDto ();公共类ExampleDto{公共字符串TextValue {get;设置;}公共bool Value1 {get;设置;}公共bool Value2 {get;设置;}}