2016-04-06 37 views
0

MVC WebGridの特定の値のセットにツールチップを追加するにはどうすればよいですか?このツールヒントの目的は、バックエンドデータベースに配置された動的な価格を示すことです。ユーザーが行1の後に列6の任意のセルを移動すると、ツールチップが表示されます。私はBootstrap Tooltipsを見ましたが、私はどのセレクターを使用するのか不明です。目的の列は赤で次のようになります。jQuery Webgrid内の動的なツールチップ

Desired Webgrid Cells for Tooltip

ここに私のMVCのためのコードスニペットは、WebGridをされています

@grid.GetHtml(
    htmlAttributes: new { id="productSearchGrid" }, 
    mode:WebGridPagerModes.All, 
    tableStyle: "table table-hover table-bordered table-responsive", 
    columns: grid.Columns(
     grid.Column("ID", "Product ID", style: "span1", canSort: true), 
     grid.Column("ProductTypeDescription", "Product Type", style: "span2", canSort: true), 
     grid.Column("ProductName", "Product Name", style: "span2", canSort: true), 
     grid.Column("Price", "Current Price", format: (item) => String.Format("{0:C}", @item.Price), style: "span2", canSort: true), 
     grid.Column("EffectiveDate", "Effective Date", (format: (item) => (item.EffectiveDate != DateTime.MinValue && item.EffectiveDate 
      != null ? new HtmlString(
      item.EffectiveDate.ToString("yyyy-MM-dd") 
      ).ToString() : new HtmlString("---").ToString())), style: "span2", canSort: false), 
     grid.Column("TerminateDate", "Terminate Date", (format: (item) => (item.TerminateDate != DateTime.MinValue && item.TerminateDate 
      != null ? new HtmlString(
      item.TerminateDate.ToString("yyyy-MM-dd") 
      ).ToString() : new HtmlString("---").ToString())), style: "span2", canSort: false), 
     grid.Column("Select", format: (item) => 
      new HtmlString(
      Html.ActionLink("Select", "AddOrEditProduct", "Product", new 
       { 
        productID = item.ID 
       }, null).ToString() 
      ) 
     ) 
    ) 
) 

編集:私はhereと非常に類似した何かを達成したいし。

答えて

0

this SOの回答を確認したところ、特定の列(列ヘッダーを除く)にツールチップを表示する方法を理解できました。最新のコードスニペットは次のとおりです。

@grid.GetHtml(
    htmlAttributes: new { id="productSearchGrid" }, 
    mode:WebGridPagerModes.All, 
    tableStyle: "table table-hover table-bordered table-responsive", 
    columns: grid.Columns(
     grid.Column("ID", "Product ID", style: "span1", canSort: true), 
     grid.Column("ProductTypeDescription", "Product Type", style: "span2", canSort: true), 
     grid.Column("ProductName", "Product Name", style: "span2", canSort: true), 
     grid.Column("Price", "Current Price", format: (item) => String.Format("{0:C}", @item.Price), style: "span2", canSort: true), 
     grid.Column("EffectiveDate", "Effective Date", (format: (item) => (item.EffectiveDate != DateTime.MinValue && item.EffectiveDate 
      != null ? new HtmlString(
      item.EffectiveDate.ToString("yyyy-MM-dd") 
      ).ToString() : new HtmlString("---").ToString())), style: "span2", canSort: false), 
     grid.Column("TerminateDate", "Terminate Date", (format: (item) => (item.TerminateDate != DateTime.MinValue && item.TerminateDate 
      != null ? @Html.Raw(("<span id='' title='" + item.Price + "'>" + item.TerminateDate.ToString("yyyy-MM-dd") 
      ).ToString() + "</span>") : new HtmlString("---").ToString())), style: "span2", canSort: false), 
     grid.Column("Select", format: (item) => 
      new HtmlString(
      Html.ActionLink("Select", "AddOrEditProduct", "Product", new 
       { 
        productID = item.ID 
       }, null).ToString() 
      ) 
     ) 
    ) 
) 
関連する問題