Question

I'm creating a search page, the page has a form that is being submitted using Ajax, after the search is performed I want to display a grid with the results.

My question is, should I create the grid when the page loads and then fill it with the data after the search is performed, or create the grid on the server when the search is performed and then just append the grid to the page.

I was thinking on creating a helper method to render the grid and invoking it from the controller after it gets the results, then returning the result of the helper method and appending it to the page, but this might be against MVC architecture (I'm defining UI on the controller).

What approach should I take?

Thanks

Was it helpful?

Solution

You could use jqGrid (http://www.trirand.com/blog/) or Flexigrid (http://www.flexigrid.info/) and load data with ajax and json. You submit search form with ajax, controller returns JsonResult, and then you load it into grid in callback. It is easy to implement and gives you additional functionalities (sorting and much, much more). Here you have some demos:

http://trirand.com/jqgrid/jqgrid.html

OTHER TIPS

for the grid creation, you can have a look at MVCContrib grid helper

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top