I have used a WebGrid
in my asp.net mvc4 application
<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="proper@(@i)" type="checkbox" />}</span>)))
</td>
Css
.table_div {
overflow-y: scroll;
width: 400px;
height: 200px;
position: relative;
}
I'd like to add a vertical scrolling to my grid but it didn't work.
Generated 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>
- What is the error?
- How can i fix it?
Put your table inside a div with class
.table_div
Your structure should be like :
You should wrap the
table
in adiv
and apply class to that divWorking Demo
Eg: