1

我正在使用 Kendo UI Server Side Wrappers 创建一个网格来管理(CRUD)我们系统中的消息列表。该模型非常简单,只要求消息不超过 150 个字符。为了强制消息长度,我在模型中使用了以下数据注释:

[StringLength(150, ErrorMessage = "Message exceeded the maximum length allowed.  Please ensure you message is no longer than 150 characters")]        

这是我的网格的样子:

@model OperatorMessageListModel

@{
    TransactionStatusType status = Model.TransactionStatus;
    ViewBag.Title = String.Format("{0} Transaction Operator Messages", status);
    string header = string.Format("{0} Transaction Messages", status);
    string messagesTableId = string.Format("{0}TransactionOperatorMessagesGrid", status);
}

<h2>@header</h2>

@(Html.Kendo().Grid(Model.OperatorMessages)
      .Name(messagesTableId)
      .TableHtmlAttributes(new { style = "width: 50% height:75%" })
      .Columns(columns =>
                   {

                       columns.Bound(m => m.Message).Title("");
                       columns.Bound(m => m.Index).Hidden(true);
                       if (!Model.IsInherited) //only edit if you own the list and there's anyhting to edit
                       {
                           columns.Command(cmd =>
                                               {
                                                   cmd.Edit().UpdateText("Save");
                                                   cmd.Destroy();
                                               }).Width("20%");

                       }
                   })
     .Pageable()
     .Scrollable(s => s.Enabled(false))
     .ToolBar(cmd =>
                  {

                      if (!Model.IsInherited) //you can add messages to the lists that you own
                      {
                          cmd.Create().Text("Add new message");
                      }

                      if (!Model.OwnedByRoot && Model.OperatorMessages.Any()) //if the root owns this it can't override or inherit its own list.
                      {
                          var actionName = Model.IsInherited ? "OverrideTrasactionMessageList" : "InheritTrasactionMessageList";
                          cmd.Custom().Text(Model.OverrideOrInheritButtonText).Action(actionName, "OperatorMessage", new { Model.OrgId, Model.TransactionStatus });
                      }
                  }
           )

     .Editable(editable => editable.Mode(GridEditMode.InLine))
     .DataSource(ds => ds
        .Server()
        .Model(model => model.Id(m => m.Index))
        .Create(c => c.Action("CreateTransactionMessage", "OperatorMessage", new { @Model.OrgId, @Model.TransactionStatus }))
        .Read(c => c.Action("List", "OperatorMessage", new { @Model.OrgId, @Model.TransactionStatus }))
        .Update(c => c.Action("EditTransactionMessage", "OperatorMessage"))
        .Destroy(c => c.Action("DeleteTrasactionMessage", "OperatorMessage"))

     )
)

这是控制器代码:

[HttpPost]
public ActionResult CreateTransactionMessage([DataSourceRequest] DataSourceRequest request,
                                                 OperatorMessageModel newMessage, string OrgId,
                                                 string TransactionStatus)
{

    _transactionOperatorMessageService.AddOperatorMessage(OrgId, TransactionStatus, newMessage,
                                                          CurrentUser.Name());
    return RedirectToAction("List", new {OrgId, TransactionStatus});
}

当用户输入超过 150 个字符的消息时,我希望向用户显示验证消息。此外,表单不会被发送回控制器。在 Chrome 和 Firefox 中一切正常。但是,在 IE8 中显示消息,但仍将表单发送回控制器。有人见过这个吗?

4

0 回答 0