GridView behaviour in MVC
Hi, I'm working on MVC2 based web solution where it have HTMLHelpers to render various kinds of controls over the view. But in the ASP Web Form based solutions there is one of the good control GridView which facilitates user with numerous kinds of things in addition to display the records i.e. add/delete/edit the record, paging and so on. Is this possible in MVC2 or MVC3? or is there any alternative that facilitate some behavior not same but like this with most required things within same location.
Re: GridView behaviour in MVC
The GridView is an ASP.NET server control. Server controls get processed by ASP.NET and replaced with the appropriate HTML. In MVC, there are no server controls. It's up to you to generate the appropriate HTML. You can write your own methods to output the exact same HTML code as a GridView if you want, but it's up to you to do it.
You may want to consider using a jQuery grid instead of doing it all in HTML yourself.
http://www.trirand.com/blog/
Re: GridView behaviour in MVC
yep, you got to let go with the things webforms spoiled you with.
ideally you want to build your own (it's just a table of records with paging for the most cases anyhow)
You do have a few other options though (Those I know from the top of my head, just google it)
MvcContrib Grid
Telerik
jQuery Grid
Re: GridView behaviour in MVC
It's worth noting that the new MVC3 (currently at RC2) includes a WebGrid class that can be used, via a helper method, to build what is essentially the equivalent of a WebForms GridView. There is also jqGrid, which is a free jQuery plugin that provides a very functional grid that is easy to use in an MVC app.
Re: GridView behaviour in MVC
Quote:
Originally Posted by
jmcilhinney
It's worth noting that the new MVC3 (currently at RC2) includes a WebGrid class that can be used, via a helper method, to build what is essentially the equivalent of a WebForms DataGrid.
Cool. Just started out with MVC3 and did not notice that. :thumb:
Re: GridView behaviour in MVC
Quote:
Originally Posted by
jmcilhinney
It's worth noting that the new MVC3 (currently at RC2) includes a WebGrid class that can be used, via a helper method, to build what is essentially the equivalent of a WebForms GridView. There is also jqGrid, which is a free jQuery plugin that provides a very functional grid that is easy to use in an MVC app.
Hi, Thank you jmcilhinney, thats greate......I'll go through WebGrid. Have you any good link containing discussion about this helper method to grasp this quickly.
Re: GridView behaviour in MVC
Quote:
Originally Posted by
jivangoyal
Hi, Thank you jmcilhinney, thats greate......I'll go through WebGrid. Have you any good link containing discussion about this helper method to grasp this quickly.
Unfortunately there isn't a lot around at the moment. Everything I found was for MVC3 beta and some things have changed a little in the RC. I just searched, read what I could and experimented a bit. I also opened the relevant assembly in .NET Reflector to get a clear idea of exactly what functionality was available.
Re: GridView behaviour in MVC
Quote:
Originally Posted by
jmcilhinney
I just searched, read what I could and experimented a bit. I also opened the relevant assembly in .NET Reflector to get a clear idea of exactly what functionality was available.
Prodding around in the MVC3 Source code also helps. (Though it seems only MVC 3 Beta source code are available.)
What I like to do is add the source code to my project, and reference that project instead of Mvc dll's. Rather not do that with the MVC3 site I'm building now though. Not sure what changed between Beta and RC2
Re: GridView behaviour in MVC
The best thing about MVC3 is RAZOR engine support, its so much cleaner than WebForms engine:)