Lamloumi Afif Lamloumi Afif - 1 year ago 56
Javascript Question

Convert table to datagrid within razor view

I have an mvc4 application with Razor. In the view


<td>Propriétés correspondantes à l'élément</td>
<table class="table_form">
Features_Management.Models.Chef chef = new Features_Management.Models.Chef();
List<Features_Management.Models.Property> list_prop = chef.Get_List_Property();

@for (int item = 0; item < list_prop.Count; item++)
<td><input type="checkbox" name="proper@(item)" /></td>

i'd like to convert this table to a
to view the with the possibility of scrolling.


How can i do this task?Any suggestions?

Answer Source

You can use a WebGrid.

You can understand how it works and improve it by reading this:

Get the Most out of WebGrid in ASP.NET MVC

Once you have your table generated, you can use a jQuery plugin like this: jQuery Scrollable Table Plugin. There is sample code to see how it works.

This scriptbe triggered on the $(document).ready(...) of the page (or in the ajax callback, if you're loading it by using jQuery).

Theere are more plugins similar to this one which make the same function. Google "scrollable table jquery plugins".

(Naurally, you need to also include jQuery in your project, if you're not still using it).