【发布时间】:2023-04-05 22:26:01
【问题描述】:
我有一个实体文档:
public class Document : EntityBase
{
public Guid ID { get; set; }
public string Description { get; set; }
public string SourceLink{ get; set; }
public bool IsFile { get; set; }
}
我正在使用 Kendo Grid 内联编辑模式。
现在我想让属性string SourceLink 可编辑,这取决于bool IsFile。
这意味着如果IsFile==false,SourceLink 应该是可编辑的。
_documentsView.cshtml:
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error"))
.Model(model =>
{
model.Id(o => o.ID);
model.Field(o => o.SourceLink).DefaultValue("");
model.Field(o => o.Description).DefaultValue("");
if (model.Field(o => o.IsFile) == true) {
model.Field(o => o.SourceLink).Editable(false)
}
else
{
model.Field(o => o.SourceLink).Editable(true)
}
}
)
//.Create(update => update.Action("GridEditingInlineCreate", "Document", new { area = "" }))
//.Read(...)
//...
)
是否有可能使.Model 语句中的这个 if 语句起作用?
还是通常可以使用这种依赖的可编辑功能?
也许以另一种方式?
【问题讨论】:
-
我想我会用两个网格绕过这个要求。一个包含 IsFile==true 的元素,第二个包含 IsFile==false 的元素。所以我可以单独处理 Editable(true/false) 选项。
标签: asp.net-mvc razor kendo-ui kendo-grid kendo-asp.net-mvc