簡體   English   中英

Kendo網格驗證不適用於自定義網格行為

[英]Kendo grid validation not working with custom grid behavior

我無法通過驗證在我的自定義網格中工作。 網格旨在更改已編輯單元格下方的單元格值。 在兩個單元格都具有新值之后,將單元格焦點設置到下一個單元格(如果按下Enter / Tab鍵,或者在下一個鼠標單擊的單元格中都位於右側單元格)。 為了使所有這些正常工作,我必須編寫自定義的refresh()current()函數,並在網格中使用自定義的edit()save()事件。 我還在單元格中使用自定義編輯器,該編輯器刪除了微調框並選擇了單元格的值。

我做了一個簡化的工作示例,它表明驗證不起作用。 在示例中,您可以在第一行中編輯單元格,然后按Enter或Tab鍵,下面的單元格將獲得與編輯后的單元格相同的值。 為了使鼠標和鍵盤都能夠正常工作,自定義功能和事件是必需的,因此我必須使用它們。

如果刪除單元格的值,然后按Enter鍵,則不會顯示驗證錯誤。 我想這與我使用的所有自定義函數和事件有關。 有沒有辦法使驗證工作?

我可以正常使用,問題出在自定義列編輯器功能之內。 Telerik的家伙為我提供了解決方案:

由於缺少驗證屬性,因此未觸發驗證。 您可能知道,使用自定義列編輯器時,開發人員負責將適當的驗證屬性添加到此編輯器中的正確元素。

function editNumberWithoutSpinners(container, options) {

    // add name attribute to connect the validation placeholder with the validated element
    $('<input name="' + options.field + '" data-text-field="' + options.field + '" ' +
        'data-value-field="' + options.field + '" ' +
        'data-bind="value:' + options.field + '" ' +
        'data-format="' + options.format + '" required="required"/>') // add the validation attributes
        .appendTo(container)
        .kendoNumericTextBox({
            spinners: false,
            min: 0
        });

    // custom validation message placeholder is required due to the way NumericTextBox is rendered
    $('<span class="k-invalid-msg" data-for="' + options.field + '"></span>').appendTo(container);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM