This is a migrated thread and some comments may be shown as answers.

[Solved] [Bug] Strange validation error in inline editor?

1 Answer 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Joan Vilariño
Top achievements
Rank 2
Joan Vilariño asked on 29 Sep 2010, 10:39 AM
Hello.

I've stumbled today with a bug in grid editor that's driving me crazy... I had it in a form on my application, and after two hours looking for it, I decided to check if it was telerik's fault. So, I copied the column template to a simpler test project I had already used before, and the same error pops.

I have this model:

namespace ComboTest.Models
{
    public class HomeViewModel
    {
        public long Id { get; set; }
        public long ItemId { get; set; }
        public HomeItem Item { get; set; }
        [UIHint("CodigoPeticion")]
        public string Comment { get; set; }
          
    }
  
    public class HomeItem
    {
        public long Id { get; set; }
        public string Name { get; set; }
    }
}

then I have this Index page:

<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="ComboTest.Models"%>
<%@ Import Namespace="Telerik.Web.Mvc.UI"%>
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <%= Html.Telerik().StyleSheetRegistrar()
        .DefaultGroup(group => group.Add("telerik.common.css")
                                    .Add("telerik.default.css"))
    %>
</head>
<body>
<h2>Index</h2>
  
<%=Html.Telerik().Grid<HomeViewModel>()
    .Name("GridItems")
    .ToolBar(tb => tb.Insert())
    .Pageable(page => page.PageSize(15))
        .Sortable(order => order.OrderBy(o => o.Add(e => e.Item.Name)).SortMode(GridSortMode.MultipleColumn))
            .Scrollable(scroll => scroll.Height(300))
    .DataBinding(db => db.Ajax().Select("_Select","Home")
                                .Update("_Update","Home")
                                .Insert("_Insert","Home")
                                .Delete("_Delete","Home"))
    .DataKeys(dk => dk.Add(o => o.Id))
    .Editable(ed => ed.Enabled(true))
    .Columns(cl =>
                 {
                     cl.Command(cm =>
                                    {
                                        cm.Edit();
                                        cm.Delete();
                                    }).Width(180);
                     cl.Bound(o => o.Item).ClientTemplate("<#= Item.Name #>").Width(150);
                     cl.Bound(o => o.Comment);
                 })%>
  
  
<% Html.Telerik().ScriptRegistrar().Render(); %>
</body>

and this is the template for the comment column I'm getting the error on:

<%@ Import Namespace="Telerik.Web.Mvc.UI"%>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %>
<div id="CodigoPeticionInversion" style="display:block; white-space:nowrap">
<select name="listaTipos">
    <option value=""></option>
    <option value="OPE">OPE</option>
    <option value="BIN">BIN</option>
    <option value="SAL">SAL</option>
</select>
<select name="listaAnyos">
    <option value=""></option>
    <%for (var i = DateTime.Today.Year; i > DateTime.Today.Year - 5; i--) { %>
    <option value="<%=i %>"><%=i %></option>
    <% } %>
</select>
<input type="text" id="digitos5" maxlength="5" style="width:40px" />
<input type="text" id="digitos3" maxlength="3" style="width:30px" />
<%=Html.HiddenFor(o => Model) %>
</div>

Ok .. here's the problem:

When I click edit or Add new record in the grid, the template shows as expected, but if I type anything in any of the two input fields "digitos5" or "digitos3", I get an error in "telerik.grid.editing.js" when the text input loses focus.... the error is:

'removeClass(...).attr(...)'  is null or not an object

at telerik.grid.editing.js in a line that reads

v.removeClass(

"input-validation-error").attr("_for_validation_message",x).appendTo(x)

Can you try to reproduce this error on your end to confirm the bug?

Cheers!!

 

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 29 Sep 2010, 01:03 PM
Hi Joan VilariƱo,

 I confirm that this is a bug. You can fix it by modifying telerik.grid.editing.js from the source code distribution. Find the errorPlacement method and change it like this (the new code is highlighted)

            errorPlacement: function(error, element) {
                var messageSpan = fieldToMessageMappings[element.attr("name")];
                if (messageSpan) {
                    $(messageSpan).empty()
                                .removeClass("field-validation-valid")
                                .addClass("field-validation-error")

                    error.removeClass("input-validation-error")
                     .attr("_for_validation_message", messageSpan)
                     .appendTo(messageSpan);
                }
            }

I have updated your telerik points.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Joan Vilariño
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Share this question
or