0
我正在使用Kendo UI Grid内嵌编辑功能。对于不同的条件,如重复等,我显示错误消息。我该如何将错误消息发送到Fadeout? jQuery fadeOut()方法不起作用。Kendo UI网格错误消息到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>
非常感谢您......伟大工程。我错过了那部分。 – Supratim