我正在使用 Kendo UI Grid 内联编辑功能。对于重复等不同的条件。我正在显示错误消息。如何使错误消息淡出?jQuery fadeOut() 方法不起作用。
<pre><code>
<script type="text/kendo-template" id="message">
<div class="k-widget k-tooltip k-tooltip-validation k-invalid-msg field-validation-error" style="margin: 0.5em; display: block; " data-for="#=field#" data-valmsg-for="#=field#" id="#=field#_validationMessage">
<span class="k-icon k-warning"> </span>#=message#<div class="k-callout k-callout-n">
</div>
</script>
<script type="text/javascript">
var validationMessageTmpl = kendo.template($("#message").html());
function error(args) {
if (args.errors) {
var grid = $("#DocumentGrid").data("kendoGrid");
grid.one("dataBinding", function (e) {
e.preventDefault(); // cancel grid rebind if error occurs
for (var error in args.errors) {
showMessage(grid.editable.element, error, args.errors[error].errors);
$("#GridError").fadeOut(1000);
}
});
}
}
function showMessage(container, name, errors) {
//add the validation message to the form
$("#GridError").replaceWith($(validationMessageTmpl({ field: name, message: errors[0] })));
}
</script>
<div id="GridError"></div>
<div style="width:600px; float:left; margin-top:0px; margin-top:35px;">
<%: Html.Kendo().Grid<DocumentModel>().HtmlAttributes(new { @class = "grid" })
.Name("DocumentGrid")
.Columns(columns =>
{
columns.Bound(p => p.DocumentId).Hidden(true);
columns.Bound(p => p.DocumentName).Title("Document Name");
columns.Command(command =>
{
command.Edit();
})
.Width(50)
.HtmlAttributes(new { @Style = "white-space: nowrap; overflow: hidden;" });
})
.Pageable()
.Sortable()
.Filterable()
.ToolBar(toolbar => toolbar.Create().Text("Add Document"))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(true)
.Sort(sort =>
{
sort.Add(m => m.DocumentName);
})
.Events(events => events.Error("error"))
.Model(model => model.Id(c => c.DocumentId))
.Create(update => update.Action("DocumentGrid_Create", "Admin"))
.Read(read => read.Action("DocumentGrid_Read", "Admin"))
.Update(update => update.Action("DocumentGrid_Update", "Admin"))
)
%>
</div>
</code></pre>