Asp.net mvc 剑道网格编辑内联模型.Field(o=>o.Property).Editable(),具体取决于其他属性

Asp.net mvc 剑道网格编辑内联模型.Field(o=>o.Property).Editable(),具体取决于其他属性,asp.net-mvc,razor,kendo-ui,kendo-grid,kendo-asp.net-mvc,Asp.net Mvc,Razor,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,我有一份实体文件: public class Document : EntityBase { public Guid ID { get; set; } public string Description { get; set; } public string SourceLink{ get; set; } public bool IsFile { get; set; } } 我使用剑道网格内联编辑模式。 现在我想让属性字符串SourceLink可编辑,这取决于b

我有一份实体文件:

public class Document : EntityBase
{
    public Guid ID { get; set; }
    public string Description { get; set; }
    public string SourceLink{ get; set; }
    public bool IsFile { get; set; }
}
我使用剑道网格内联编辑模式。 现在我想让属性字符串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的标签。否则,我认为您会被当前的解决方案所困扰,因为可编辑性是在数据源上设置的,而不是在行级别


不过还有一个需要考虑的问题-您可能可以使用共享编辑器模板来编写标签,而不是使用编辑器…

我想我将使用两个网格来绕过这一要求。一个包含IsFile==true的元素,第二个包含IsFile==false的元素。因此,我可以分别处理Editabletrue/false选项。