سؤال

I'm building a system in MVC that has a lot of heterogeneous data to be displayed: Customers, logs, etc.

I'm finding that I'm building the same view over and over again in different forms:

  • Header row (with sorting links)
  • Filter row (drop-downs, date pickers, etc.)
  • Data
  • Paging row

Naturally the abstractor in me is shouting "Build a generic data view factory!", as well it should. However, before I disappear up my own abstracting bottom, has this work already been done elsewhere?

The only option I can currently find is MVCContrib.Grid, which doesn't seem to handle the rendering of filters (although it has allowances for extending the renderer). Is this the only option?

هل كانت مفيدة؟

المحلول

As one may expect a question similar to your has already been done...years ago. So here: grid controls for ASP.NET MVC? you can find a list available data grids, that has been updated in the years. I recommend that you, once and for all, give a look to all of them, so in the furure you may choose the more adequate to your needs. There is no better grid, but each of them has advantages and disadvantages.

نصائح أخرى

Yes, I could recommend this jQuery plugin

http://datatables.net/

My Choice would be between

  • datatables.net (Already mentioned)

  • jqGrid (http://www.trirand.net/demoaspnetmvc.aspx)

I've foud the datatables easier to use at first, but finally I've used jqGrid as I've foud it more powerfull.

I've used both KendoUI and jqGrid successfully. jqGrid is a light-weight and less expensive solution if all you are looking for is a grid. One of the things I liked about jqGrid aside from its easy integration with knockout was it's ability to edit data in table cells as well as creating a "edit view" in which the data is edited in a form-type view with labels beside edit widgets.

That said, it sounds like you might be looking for more than a grid, and if so you should also look at using Html helpers to generate the constituant parts (header w/filter, data rows, paging, etc). This would give you ultimate flexibility over where the different parts are rendered on the page. Maybe you want to put the paging controls twice on the page at the top and bottom; maybe you want to put the filtering into a modal dialog box. The ability to simply go:

@Html.FilterControlsFor(Model.PhoneBookUsers) 

someplace (or someplaces) on a page and have the helper deal with all of the details is pretty powerful juju.

Flexigrid - nice table plugin, but it is only ui table you should provide appropriative server side processing for selection and filtering data.

KendoUI any day. Theres a ASP.NET wrapper but it's quite expensive. But the jQuery lib is definitly the best out there.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top