teleriktelerik-gridtelerik-mvchtmlhtml-title

Telerik MVC Grid: Row specific content in a HtmlAttributes


Is it posible to use row specific content into HtmlAttributes?

I got this cell with its content (o.ArrivalTime), when i move my mouse over it i'll like it to show the content from a other element (o.Note) in a tooltip

I tried this but it will not accept the o.Note

columns.Bound(o => o.ArrivalTime)
  .Title("Arrival Time")
  .Template(o =>
        {%><%=(o.ArrivalTime < Convert.ToDateTime("2000-01-01")) ? "?" : o.ArrivalTime.ToString()%><%})
  .Width(140)
  .HtmlAttributes(new {title = o.Note })
  ;

Solution

  • Rather than using HtmlAttributes, you can do this inside Template.

    columns.Bound(o => o.ArrivalTime)
      .Title("Arrival Time")
      .Template(o =>
        {%><div title="<%= o.Note %>"><%=(o.ArrivalTime < Convert.ToDateTime("2000-01-01")) ? "?" : o.ArrivalTime.ToString()%></div><%})
      .Width(140)
      ;