ReflectionIT.Mvc.Paging
ReflectionIT.Mvc.Paging copied to clipboard
Is it possible to use my own model class, instead of PagingList<T>?
Hi,
Is it possible to use my own model class, instead of PagingList<T>?
I would like to have a MyViewModel class as the model, with one of its properties being PagingList<T>.
This way I could have more properties in my model class (unrelated to paging).
Thanks
@leodip Did you ever figure this out?
@leodip - You can definitely do this. You just need to do something like this:
public class ReportCategoryViewModel
{
public PagingList<ReportListViewModel> Reports;
public SelectList Categories;
public string Category { get; set; }
}
And then in your controller, something like this:
var model = PagingList.Create(reports, 10, pageNumber, sort, "Name");
var reportCategoryVM = new ReportCategoryViewModel
{
Categories = categories,
Reports = model
};
return View(reportCategoryVM);
Hope this helps!
Can you create a project for this problem and publish it in a public github repository? I will have a look at it. Don't have time to create one myself.