2014-01-15 34 views
0

我在我的asp.net應用mvc4使用WebGrid添加一個垂直滾動內Asp.net mvc4應用的WebGrid

<td > 
        @grid.GetHtml(tableStyle:"table_div", 
        headerStyle:"table_header", 
        columns: grid.Columns(
        grid.Column("Nom de la propriété","Nom de la propriété",canSort:false,format:@<label>@Html.Raw(@item.PName)</label>), 
        grid.Column("Valeur de la propriété","Valeur de la propriété",canSort:false,format:@<label>@Html.Raw(@item.PName)</label>), 
        grid.Column("","",canSort:false,format:@<span>@{i++;<input name="[email protected](@i)" type="checkbox" />}</span>))) 
      </td> 

的CSS

.table_div { 
    overflow-y: scroll; 
    width: 400px; 
    height: 200px; 
    position: relative; 
} 

我想添加垂直滾動到我的網格,但它不起作用。

生成的HTML

<table class="table_div"> 
    <thead> 
     <tr class="table_header"> 
      <th scope="col"> 
Nom de la propriété   </th> 
      <th scope="col"> 
Valeur de la propriété   </th> 
      <th scope="col"> 
      </th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
      <td><label>poids</label></td> 
      <td><label>poids</label></td> 
      <td><span><input name="proper0" type="checkbox"></span></td> 
     </tr> 
     <tr> 
      <td><label>taille</label></td> 
      <td><label>taille</label></td> 
      <td><span><input name="proper1" type="checkbox"></span></td> 
     </tr> 

    </tbody> 
    </table> 
  1. 什麼錯誤?
  2. 我該如何解決?
+1

嘗試把你的表一個div內與類'.table_div' – Era

+0

看到我的編輯,請 –

+0

看到我的回答。你的結構應該只有這樣。 – Era

回答

2

把你的表一個div裏面有.table_div

您的結構應該是這樣的:

<div class="table_div"> 
    <table> .. 
</div> 
+0

Simplicity是Genius的商標.. :) – Anup

+1

:D ..感謝您使用Genius字給我。我欠你。 – Era

+0

感謝您的評論..! – Anup

1

你應該換一個divtable和應用類,該div

Working Demo

如:

<div class="table_div"> 
<table> 
... 
</table> 
</div> 
+0

請參閱我的編輯請 –