ASP.Net MVC: Showing the same data using different layouts...

Posted by vdh_ant on Stack Overflow See other posts from Stack Overflow or by vdh_ant
Published on 2010-05-18T02:34:51Z Indexed on 2010/05/18 2:41 UTC
Read the original article Hit count: 263

Hi guys

I'm wanting to create a page that allows the users to select how they would like to view their data - i.e. summary (which supports grouping), grid (which supports grouping), table (which supports grouping), map, time line, xml, json etc.

Now each layout would probably have different use a different view model, which inherit from a common base class/view model. The reason being that each layout needs the object structure that it deals with to be different (some need hierarchical others a flatter structure).

Each layout would call the same repository method and each layout would support the same functionality, i.e. searching and filtering (hence these controls would be shared between layouts). The main exception to this would be sorting which only grid and table views would need to support.

Now my question is given this what do people think is the best approach.

  • Using DisplayFor to handle the rendering of the different types?
  • Also how do I work this with the actions... I would imagine that I would use the one action, and pass in the layout types, but then how does this support the grouping required for the summary, grid and table views.
  • Do i treat each grouping as just a layout type
  • Also how would this work from a URL point of view - what do people think is the template to support this layout functionality

Cheers Anthony

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about best-practices