2

行固有のコンテンツをHtmlAttributesに使用することは可能ですか?

このセルとそのコンテンツを取得しました(o.ArrivalTime)。マウスをその上に移動すると(o.Note)、ツールチップ内の他の要素のコンテンツが表示されるようになります。

私はこれを試しましたが、それは受け入れられません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 })
  ;
4

2 に答える 2

2

HtmlAttributesを使用する代わりに、テンプレート内でこれを行うことができます。

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)
  ;
于 2012-07-13T13:54:21.240 に答える
0

次の例を見てください。

グリッド-サーバーテンプレート

この例では、最初の列はテンプレートメカニズムを使用して列を作成します。同様の方法で、列のテンプレートを作成し、テンプレートを定義するときに別の列を使用できます。デモのコードスニペットは次のとおりです。

<% Html.Telerik().Grid(Model)
    .Name("Grid")
    .Columns(columns => 
    {
        //Template column. The grid displays the HTML defined by the argument.
        columns.Template(c => {
        %>
            <img 
                alt="<%= c.CustomerID %>" 
                src="<%= Url.Content("~/Content/Grid/Customers/" + c.CustomerID + ".jpg") %>" 
              />
        <%
        });
        //Regular databound column. The grid displays the value of the CustomerID property.
        columns.Bound(c => c.CustomerID);
    })
    .Render();

%>

これがあなたの質問に役立つことを願っています。

Lohith(Tech Evangelist、Telerik India)

于 2012-07-14T08:28:41.493 に答える