2

替代文字 当我编辑一行时 ,我有一个 Telerik 网格 :替代文字 但是如果我按下更新按钮甚至取消(观看中间列): 替代文字

这是声明:

    <%= Html.Telerik().Grid<AlefTech.HumanResource.WebModule.ViewDto.MaritialStatusItemEditDto>(Model)
        .Name("Grid")
        .DataKeys(keys => { keys.Add(c => c.MaritialStatusItemID); keys.Add(k => k.Index); })
        .Columns(columns =>
        {
            //columns.Bound(m => m.MaritialStatusItemID).Visible(false);
            columns.Bound(m => m.Index).Title("").Sortable(false).Width(0);
            columns.Bound(m => m.Name);
            //columns.Bound(m => m.Brithdate).Width(130).Format("{0:d}");
            //columns.Bound(m => m.Gender);
            columns.Bound(m => m.MaritialStatusItemType);
            //columns.Bound(m => m.Notes);
            //columns.Bound(m => m.Status);
            //columns.Bound(m => m.CreationDate);
            //columns.Bound(m => m.ItemGuid);//.ClientTemplate("<input type='hidden' value='<#ItemGuid#>' name='ItemGuid' id='WorkerID'>");
            columns.Command(command => { command.Edit(); command.Delete(); });
        })
       //.ClientEvents(cfg => cfg.OnDataBound("onRowDataBound"))
        .ToolBar(t => t.Insert())
        .DataBinding(d => d.Ajax()
            .Select("MartialStatusGridSelect", "Worker")
            .Insert("MartialStatusGridInsert", "Worker")
            .Update("MartialStatusGridUpdate", "Worker")
            .Delete("MartialStatusGridDelete", "Worker"))
        .Scrollable()
       .Editable(editing => editing.Enabled(true))
        .Sortable()
        .HtmlAttributes(new { @class = "t-grid-rtl", @hegiht = "450px" })
        .Pageable()

%>

和模型:

   public class MaritialStatusItem : BaseEntity
    {
        [StringLength(50)]
        [Required]
    public virtual string Name { get; set; }

        [UIHint("MaritialStatusEnum")]
        public virtual MilitaryStatusEnum MaritialStatusItemType { get; set; }
    }

显示模板 MaritialStatusEnum.ascx

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%=((MilitaryStatusEnum)Model == .MilitaryStatusEnum.Serving)? "Serving" : "Finished"
%>

编辑器模板

   <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<AlefTech.HumanResource.Core.MartialStatusEnum>" %>
    <%=Html.DropDownList("MartialStatus", new SelectListItem[] { new SelectListItem { Text = "Serving", Value = "0" }, new SelectListItem { Text = "Finished", Value = "1" } }) %>

任何想法为什么会发生这种情况?

4

1 回答 1

1

好吧,我使用本主题中提到的方式解决了这个问题 ,如下所示:

columns.Bound(m => m.MaritialStatusItemType).ClientTemplate("<#= maritialStatusItemEnum[MaritialStatusItemType] #>");
.
.
.
<script type="text/javascript">
var maritialStatusItemEnum = ["Single person", "Married Person", "Divorced Person", "Widowed"];
</script>

并注意这是 Enum 属性的解决方案,但如果您有一个复杂的对象,您应该考虑另一种解决方案。

于 2010-09-20T07:53:03.710 回答