MVC doesn't have a replacement for the standard web forms gridview. It gives you the flexibility of using any grid you want and being close to the metal.
It does ship with a WebGrid that you can use, but there are also 3rd party vendors that provide some advanced mvc3 grids.
At moment there are several grids for Asp.net Mvc.
However to choose the right one you should understand the differences. The main axes to compare them are:
display only, single row edit, batch edit
server side, versus client side and update strategy
possibility to customize the row template
Capability to handle huge quantity of data on the client side (upto 100.000 rows)
if you need a display only grid or a diplay grid with links for edit and delete to be performed into other views....probably you just need a foreach loop as suggested by Andrei. You can add to this a pager and/or helpers to handle filtering and sorting of
data. This way you can put EVERYTHING you like in each row...like in a webforms repeater.
If you need batch editing, that is, the possibility for the user to add edit and delete several rows, and then sendig all changes together to the server, then YOU NEED a GRID CONTROL, or you have to accept to spend time to implement it with some client side
library like knockout.js
Now you can choose between server side and client side grids. A server side grid produces the Html of the grid on the server side and sent it as it is to the browser. A client side grid, instead, just receives the rough data from the server and creates the
Html of the grid dynamically on the client side. The standard
WebGrid and the
DatagridFor grid of the Mvc Controls Toolkit are server side while most of all other grids are client side.
Advantages of server side are:
Visibility to search engines
Work well also with poor client devices since most of the job is done on the server side
Rows are built on the server side, where you have access to all information you need, and you have powerfull tools like razor to shape each row.
Easy of use
Advanteges of client side:
Requires less bandwidth, since less data are exchanged between server and client
user can modify the grid options WITHOUT any server roundtrip
they can interact better with other javascript controls in the page to yield a better user experience
they can do pure client side paging/sorting and filtering. This means one send a huge quantity of data to the browser, and the browser can manipulate them locally without any server roundtrip. In most of the application it is better to send just a few data
to the browser and requiring further data only if they are needed, however in some cases this feature might be usefull.
Most of the grids listed by CodeHobo are ClientSide. Their main disadvantage is the limited possibility to customize the row template. However, if you build a grid with knockout.js you can
overcome this problem. In particular if you use the ClientBlockRepeater of the Mvc Controls Toolkit you can write your row template wiith razor...as you do with any View,
while enjoying all other advantages of Client Side grids.
The final point is the capability to handle huge amount of data on the client side without any roundtrip. Typically the grids that performs well in this doesn't allow for advanced customization of the row template...and you must substantially use the "standard
grid appearence" of "tabular data". If you just need a "standard"(standard in the appearence) grid that can handle huge quantity of data on the client side the
slickgrid is the one that performs better. It allows also a limited customization through formatters that allow the customization of how data appears in each cell.
hc1
Member
199 Points
231 Posts
GridView
Mar 27, 2012 02:39 AM|LINK
I am totally new to MVC after spending all these years on ASP.NET web forms.
What is THE replacement for GridView?
I need a really good GridView equivalent before I can migrate to MVC 3.
Thanks.
CodeHobo
All-Star
18647 Points
2647 Posts
Re: GridView
Mar 27, 2012 02:46 AM|LINK
MVC doesn't have a replacement for the standard web forms gridview. It gives you the flexibility of using any grid you want and being close to the metal.
It does ship with a WebGrid that you can use, but there are also 3rd party vendors that provide some advanced mvc3 grids.
Web Grid
http://msdn.microsoft.com/en-us/magazine/hh288075.aspx
Telerik Mvc Extensions
http://demos.telerik.com/aspnet-mvc/grid
Dev Express
http://mvc.devexpress.com/GridView/Sorting
You can also use any purely client side grid such as
JQGrid
http://www.trirand.com/blog/
KendoUI Grid
http://demos.kendoui.com/web/grid/index.html
Blog | Twitter : @Hattan
ignatandrei
All-Star
135204 Points
21687 Posts
Moderator
MVP
Re: GridView
Mar 27, 2012 05:01 AM|LINK
I addition of CodeHobo: I use
foreach
( and a pagination)
francesco ab...
All-Star
20912 Points
3279 Posts
Re: GridView
Mar 27, 2012 02:08 PM|LINK
At moment there are several grids for Asp.net Mvc.
However to choose the right one you should understand the differences. The main axes to compare them are:
if you need a display only grid or a diplay grid with links for edit and delete to be performed into other views....probably you just need a foreach loop as suggested by Andrei. You can add to this a pager and/or helpers to handle filtering and sorting of data. This way you can put EVERYTHING you like in each row...like in a webforms repeater.
If you need batch editing, that is, the possibility for the user to add edit and delete several rows, and then sendig all changes together to the server, then YOU NEED a GRID CONTROL, or you have to accept to spend time to implement it with some client side library like knockout.js
Now you can choose between server side and client side grids. A server side grid produces the Html of the grid on the server side and sent it as it is to the browser. A client side grid, instead, just receives the rough data from the server and creates the Html of the grid dynamically on the client side. The standard WebGrid and the DatagridFor grid of the Mvc Controls Toolkit are server side while most of all other grids are client side.
Advantages of server side are:
Advanteges of client side:
Most of the grids listed by CodeHobo are ClientSide. Their main disadvantage is the limited possibility to customize the row template. However, if you build a grid with knockout.js you can overcome this problem. In particular if you use the ClientBlockRepeater of the Mvc Controls Toolkit you can write your row template wiith razor...as you do with any View, while enjoying all other advantages of Client Side grids.
The final point is the capability to handle huge amount of data on the client side without any roundtrip. Typically the grids that performs well in this doesn't allow for advanced customization of the row template...and you must substantially use the "standard grid appearence" of "tabular data". If you just need a "standard"(standard in the appearence) grid that can handle huge quantity of data on the client side the slickgrid is the one that performs better. It allows also a limited customization through formatters that allow the customization of how data appears in each cell.
Mvc Controls Toolkit | Data Moving Plug-in Videos