1

这是我使用 aspl.net mvc 包装器的剑道网格。问题是当您进行批量内联编辑时。然后点击保存。

.Create(create => create.Action("UpdateLiabilities", "Liability", parameters))

将被触发并将所有更改保存到数据库中。现在我需要添加一个回调函数来显示一个帐户成功添加的消息。我不确定如何添加此回调函数。

@(Html.Kendo().Grid<LiabilityVM>()
  .Name("QualifiedNonrecourseDebtGrid")
  .HtmlAttributes(new { style = "height: 300px;" })
  .Columns(columns =>
               {
                   columns.Bound(i => i.Id).Visible(false);
                   columns.Bound(i => i.AccountId).Visible(false);

                   columns.Bound(i => i.AccountNumber)
                       .Title("Account #")
                       .ClientTemplate("<span style='white-space:nowrap'><a href='\\#' onclick=\"showAccountInfo('acctInfoPopupContainer', " + parameters.clientId + ", " + parameters.projectId + ",#=WorkpaperId#, #=AccountId#, '#=AccountNumber#', '#=AccountNumberAndDescAndLabel#')\"> #= AccountNumber # </a></span>")
                       .HtmlAttributes(new { nowrap = "nowrap" })
                       .Width(70);
                   columns.Bound(i => i.Description)
                       .Title("Description")
                       .ClientTemplate("<span href='\\#' title='#= getEncodedValueOrDefault(Description, '')#'  style='white-space:nowrap'>#= getHtmlEncode(Description, '') #</span>")
                       .HtmlAttributes(new { nowrap = "nowrap" })
                       .Width(120);


               })
      .Editable(editable => editable.Mode(GridEditMode.InCell))
      .DataSource(grid => grid.Ajax()
                              .Batch(true)
                              .Model(model => { 
                                                model.Id(i => i.Id);
                                                model.Field(p => p.AccountNumber).Editable(false);
                              })
                              .ServerOperation(true).Group(groups => groups.Add(p => p.Source))
                              .Create(create => create.Action("UpdateLiabilities", "Liability", parameters))
                              .Read(read => read.Action("GetLiabilities", "Liability", parameters))
                              .Update(update => update.Action("UpdateLiabilities", "Liability", parameters))
                              .Aggregates(aggregates =>
                                         {
                                             aggregates.Add(p => p.TaxAdjustmentBalance).Sum();
                                         })
  )
  .Sortable()
  .Filterable()
  .Selectable(s => s.Mode(GridSelectionMode.Single))
  .Resizable(resize => resize.Columns(true))
  .Reorderable(reorder => reorder.Columns(true))
  .ColumnMenu()
  .Scrollable()
  )
4

2 回答 2

4

为此有一个特殊事件,称为sync

在您的情况下,它应该是这样的:

 .DataSource(grid => grid.Ajax().Events(ev=>ev.Sync("theNameOfTHeCallBackFUnction")))
于 2013-02-26T18:44:47.470 回答
0

在您的 UpdateLiabilities 方法中返回 jsonp 而不是 json ( JavaScriptResult) 作为

 const string alertMessage = "created";
 string aMessage = string.Format("alert('{0}');", alertMessage);
 var returned = new JavaScriptResult { Script = aMessage };
 return returned;
于 2013-02-26T16:58:31.383 回答