On a single view I will have three sets of paged data. Which means for each model I will have
- The Objects
- The Page Index
- The Page Size
My initial thought was for example:
public class PagedModel<T> where T:class
{
public IList<T> Objects { get; set; }
public int ModelPageIndex { get; set; }
public int ModelPageSize { get; set; }
}
Then having a model which is to be supplied to the action as for example:
public class TypesViewModel
{
public PagedModel<ObjectA> Types1 { get; set; }
public PagedModel<ObjectB> Typed2 { get; set; }
public PagedModel<ObjectC> Types3 { get; set; }
}
So if I then for example have the Index view inherit from the type:
System.Web.Mvc.ViewPage<uk.co.andrewrea.forum.Web.Models.TypesViewModel>
Now my initial aciton method for the index is simply:
public ActionResult Index()
{
var forDisplayPurposes = new TypesViewModel();
return View(forDisplayPurposes);
}
If I then want to page, it is here where I am struggling to decide which action to take. Lets say that I select the next page of the Types2 PageModel. What should the action look like for this in order to return the new view showing the second page of the Types2 PageModel
I was thinking possibly to duplicate the action but use it with POST
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(TypesViewModel model)
{
return View(model);
}
Is this a good way to approach it. I understand there is always Session, but I was just wondering how such a thing is achieved currently out there. If any best methods have been mutually accepted and things.
So simply, one page with multiple paged models. How to persist the data for each using a wrapper model. Which way should you pass in the model and which way should you page the data, i.e. Form Post
Lastly, I have seen the routes take this into account i.e.
{controller}/{action}/{id}/{pageindex}/{pagesize}
but this only accounts for one model and I do not really wwant to repeat the pagesize and pageindex values for the number of models I have inside the wrapper model.
Thanks for your time!!
Andrew