Unable to get message error from dropdownlist

2 posts, 0 answers
  1. Madrinha
    Madrinha avatar
    12 posts
    Member since:
    Sep 2012

    Posted 08 Jan 2013 Link to this post


    Since we update to Kendo UI Complete v2012.3.1304 we start to have a problem on the data grids. The error message is always a empty string when the is a dropdownlist.

    Inside the grid:

    <select data-bind="value: GroupId" data-val="true"  data-val-required="Erro message." id="GroupId" name="GroupId" class="k-invalid valid" aria-invalid="true">
    <option>[Selecione]</option><option value="13">item1</option><option value="47">item2</option>
    <div class="k-widget k-tooltip k-tooltip-validation k-invalid-msg field-validation-error" 
    style="margin: 0.5em;" data-for="GroupId" data-val-msg-for="GroupId" id="GroupId_validationMessage" role="alert"><span class="k-icon k-warning"> 
    </span><div class="k-callout k-callout-n"></div>

    function to get the list of erros:

    var validator = $(this).kendoValidator().data("kendoValidator");
    var val = validator.validate();
    if (!val) {
    var errors = validator.errors();
    var errorList = [];
    $.each(errors, function (key, value) {
    errorList.push({ message: value });
    return errorList;

    function from kendo.web.min.js ->

    _extractMessage: function (t, n) {
                var i = this,
                    r = i.options.messages[n],
                    o = t.attr(g);
                return r = e.isFunction(r) ? r(t) : r, a.format(t.attr(a.attr(n + "-msg")) || t.attr("validationMessage") || t.attr("title") || r || "", o, t.attr(n))

    We start to debug kendo to identify the problem. We find out that executing this function, _extractMessage: , it returns a empty string because it generates a 
    attribute name like "data-val-number". To bybass the problem we change the attribute name from data-val-required" to "data-val-number" with jquery. 

    Before call $(this).kendoValidator().data("kendoValidator"); we run this this code:

     $(this).find("select[data-val-required]").each(function (index) {

                var message = $(this).attr("data-val-required");


                $(this).attr("data-val-number", message);

    Can you help to find a better solution?
  2. Rosen
    Rosen avatar
    3216 posts

    Posted 10 Jan 2013 Link to this post

    Hello Madrinha,

    I'm afraid that it is not clear from the provided detail, what is your exact scenario and what you are trying to achieve. Are you using the KendoUI for ASP.NET MVC as the attributes set on the select elements are for ASP.NET MVC unobtrusive validation? Why and when you are instantiating a separate Kendo Validator instance if the DropDownList is already placed within grid's edit form (which already has a Validator instance)?

    Thus, it will be appreciated if you provide a small runnable test project which illustrates your scenario and the issue you are facing. 

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET AJAX banner
Back to Top