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

Single quotes not being escaped in grid ClientDetailTemplate?

1 Answer 408 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian Roth
Top achievements
Rank 1
Brian Roth asked on 23 Apr 2013, 02:05 PM
Hello All,

I set up a parent/child grid much like the Hierarchy demo.  In my case I wanted to make both grids editable (inline).  But I kept getting an invalid template error on my child grid as soon as I added the .Editable() section to it.  After some investigation and commenting/uncommenting things on the child grid and my model I discovered that the error was related to my Required validator message on the model.  My validation message was "The field '{0}' is required."  It seems like the single quotes in the validation message aren't being escaped properly when the template is created or something like that because when I changed the validation message to "The field {0} is required." everything works fine.  So I'm able to get around the issue, but I thought I'd let you know in case this is something that can be fixed in the core code.  Thanks!

Regards,
Brian

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 25 Apr 2013, 11:21 AM
Hello Brian,

Thank you for the feedback. I tried to reproduce the issue but to no avail. Probably this case is already troubleshooted, what version do you use?

Here is the setup I tried :

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(e => e.FirstName).Width(110);
            columns.Bound(e => e.LastName).Width(110);
            columns.Bound(e => e.Country).Width(110);
            columns.Bound(e => e.City).Width(110);
            columns.Bound(e => e.Title);
            
        })              
        .Sortable()
        .Pageable()
        .Scrollable()
        .ClientDetailTemplateId("template")
        .HtmlAttributes(new { style = "height:430px;" })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(6)
            .Read(read => read.Action("HierarchyBinding_Employees", "Grid"))           
        )       
        .Events(events => events.DataBound("dataBound"))
)
 
<script id="template" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
            .Name("grid_#=EmployeeID#")
            .Columns(columns =>
            {
                columns.Bound(o => o.OrderID).Width(70);
                columns.Bound(o => o.ShipCountry).Width(110);
                columns.Bound(o => o.ShipAddress);
                columns.Bound(o => o.ShipName).Width(200);
                columns.Command(cmd => cmd.Edit());
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(5)
                .Model(m=>m.Id(c=>c.OrderID))
                .Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" }))
                .Update(read => read.Action("NotImplemented", "Grid", new { employeeID = "#=EmployeeID#" }))
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )
</script>
<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>

Where OrderViewModel has the following definition:

public class OrderViewModel
    {
//...
 
        [Required(ErrorMessage = "The field '{0}' is required.Test")]
        public string ShipAddress
        {
            get;
            set;
        }


Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Brian Roth
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or