0
我在一個Kendo UI網格彈出窗口中編輯的字段使用了DropDownList,雖然驗證工具提示沒有出現問題,但它們不會消失一次輸入已被更正。Kendo UI網格彈出窗口,DropDownList驗證消息沒有被清除
我創建像這樣的DropDownList:
function serviceDropDownEditor(container, options) {
$('<input data-bind="value:' + options.field + '" data-for="' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
optionLabel: "--- select a service ---",
dataTextField: "name",
dataValueField: "id",
dataSource: window.services, // an array I've already fetched from my DB
});
}
我這個函數應用於該領域service_id
當我定義數據源,如:
columns: [
{ field: "service_id",
title: "Service",
editor: serviceDropDownEditor,
template: "#= getServiceName(service_id) #" // display the name from the id
},
要確保有一個放置驗證消息,我使用the suggestion on this page並在edit
事件期間在DropDownList下面附加佔位符跨度:
edit: function(e) {
var grid = $("#grid").data("kendoGrid")
var container = grid.editable.element
var service_container= container.find("[data-container-for=service_id]")
service_container.append('<span class="k-invalid-msg", data-for="#= field #">')
},
當有引用該字段(service_id
)的服務器端錯誤,我發現我在edit
事件創建,並與實際的消息取代它,這樣的佔位符:
var placeholder = container.find("[data-for=" + field + "].k-invalid-msg")
placeholder .replaceWith(validationMessageTmpl({ field: field, message: errors[field] }))
的驗證消息模板包含與佔位符相同的類和data-for
屬性。
它爲DropDownList顯示錯誤時效果很好,但當我糾正錯誤(並在同一表單上引入另一個表單時,所以彈出窗口保持不變)時,原始錯誤不會消失。
那麼...驗證工具提示如何清除,以及我需要做什麼?在事件中手動清除這一個?