Completed
Last Updated: 21 Feb 2023 12:05 by ADMIN
Release R2.2023-Increment.1(15.Mar.2023)
Filippo
Created on: 20 Jan 2023 13:26
Category: UI for ASP.NET MVC
Type: Bug Report
3
Formatting logic is not executed in the Grid column's HtmlAttributes

Bug report

Regression in R1 2023.

Reproduction of the problem

  1. Set the following HtmlAttributes configuration in a Grid column:
columns.Bound(p => p.OrderDate).HtmlAttributes(new { title = "Order Date: #=kendo.toString(OrderDate, 'dd-MM-yyyy')# " });

Current behavior

kendo.toString is not executed and as a result the date is not formatted. The exact value of the title attribute, as shown above is rendered as title of the cell.

Expected/desired behavior

The logic is executed and the OrderDate value is rendered in the title with the specified format.

Environment

  • Kendo UI version: 2023.1.117
  • jQuery version: x.y
  • Browser: [all]
1 comment
ADMIN
Ivan Danchev
Posted on: 21 Feb 2023 12:05

Hi,

We plan to include a fix in the upcoming release R1 2023 SP1, which is due in mid March.

As a temporary workaround, the value of the title attribute can be set with js after the Grid is loaded with data:

1. Attach a DataBound event handler to the Grid:

.Events(ev => ev.DataBound("onDataBound"))

2. Execute the following logic in the handler:

function onDataBound(e) {
    var grid = e.sender;

    grid.tbody.find("td[title*='Order Date']").each(function () {
        var row = $(this).parents('tr')
        var dataItem = grid.dataItem(row);

        var content = $(this).attr("title");
        var template = kendo.template(content);
        var title = template(dataItem);
        $(this).attr("title", title);
    });
}

Regards,
Ivan Danchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.