ReflectionIT.Mvc.Paging icon indicating copy to clipboard operation
ReflectionIT.Mvc.Paging copied to clipboard

Is it possible to use my own model class, instead of PagingList<T>?

Open leodip opened this issue 7 years ago • 3 comments

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 avatar May 18 '18 17:05 leodip

@leodip Did you ever figure this out?

billkron avatar Nov 02 '18 21:11 billkron

@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!

billkron avatar Nov 06 '18 03:11 billkron

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.

sonnemaf avatar Apr 22 '20 18:04 sonnemaf