What is the best approach to implement these features and which part of project would involved?
I see some example of JavaScript grids, but I'm talking about a general approach which best fits the MVC architec开发者_JAVA技巧ture.
I've considered configuring routes and models to implement these features but I don't have a clear idea that if this is the right approach to implementing such features. On the one hand, I think if we put logic in routes (item/page/sort/), we would have benefits like bookmarking and avoiding JavaScript. On the other hand if we use JavaScript grids, we can have behavior like the old school grid views in ASP.NET web forms.
I find that using HTML helpers may be useful for paging, but have no idea if they are good for sorting or not. I've looked at jQuery, tableSorter and quick search plug-ins, but they work just on the currently-fetched data and won't help in real sorting and filtering that may need to touch the database. I have some thoughts on using these tools side by side with AJAX to get something which works, but I have no idea if there are similar efforts done yet anywhere.
Another approach I looked at was using Dynamic Data on web forms, but I didn't find any suggestions out there as to whether or not it is a good idea to integrate MVC and DD. I know implementing filtering and sorting for an individual case is simple (although it has some issues like using Dynamic LINQ, which is not yet a standard approach), but creating a sorting or filtering tool which works in all cases is the idea I'm looking for. (Maybe this is because I want have something in hand when web form developers are wondering why I'm writing same code each time I want to implement a sort scenario for different Entities).
Here's my solution based on jqGrid: http://sprokhorenko.blogspot.com/2010/01/jqgrid-mvc-new-version-sources.html
It is a bit specific to S#arp Architecture and NHibernate, so I'm not sure if it suits your needs. But it's modular so for example it's easy to tweak base repository implementation.
Basically it's just jqGrid with all its pros and cons but integrated into MVC:
- control all formatting and editing with attributes on ViewModel
- automatic requests, sorting/filtering/paging handling
- automatic CRUD handling
- Can handle both DB and list based repositories
- no bookmarkable routes/links...
All you need is to provide ViewModel with attribute and override couple of template CRUD methods (can be as little as just InternalConstructEntity().
You could check out MVContrib, they have pretty good grid support. http://www.codeplex.com/MVCContrib
For LOB Applications the Telerik Controls might be a good solution.
I personally use jQuery DataTables. It's very simple and has a well-defined server-side request. I've written a plugin for jQuery DataTables with C# and MVC. It uses the standard jQuery DataTables request and manipulates an IQeryable instance accordingly.
精彩评论