HowToUse - HendrickxJorn/Gobln.Pager.Mvc GitHub Wiki

How to use

You can use the test project as an reference, and will give you an good idea how to use Gobln.Pager.Mvc

To add the pager to you project, reference Gobln.Pager and Gobln.Pager.Mvc to your project. You can best do this with Nuget.

After adding, reference them to the cshtml.

@using Gobln.Pager
@using Gobln.Pager.Mvc

Create an page object. And return it to the view.

    var testPage = new List<TestModel1>()
    {
        new TestModel1(){ Id = 1, Name = "Tester1", Date = new DateTime( 2015, 5,1 ) },
        new TestModel1(){ Id = 2, Name = "Tester2", Date = new DateTime( 2015, 5,2 ) },
        new TestModel1(){ Id = 3, Name = "Tester3", Date = new DateTime( 2015, 5,3 ) },
        new TestModel1(){ Id = 4, Name = "Tester4", Date = new DateTime( 2015, 5,4 ) },
        new TestModel1(){ Id = 5, Name = "Tester5", Date = new DateTime( 2015, 5,5 ) },
        new TestModel1(){ Id = 6, Name = "Tester6", Date = new DateTime( 2015, 5,1 ) },
        new TestModel1(){ Id = 7, Name = "Tester7", Date = new DateTime( 2015, 5,2 ) },
        new TestModel1(){ Id = 8, Name = "Tester8", Date = new DateTime( 2015, 5,3 ) },
        new TestModel1(){ Id = 9, Name = "Tester9", Date = new DateTime( 2015, 5,4 ) },
        new TestModel1(){ Id = 10, Name = "Tester10", Date = new DateTime( 2015, 5,5 ) },
        new TestModel1(){ Id = 11, Name = "Tester11", Date = new DateTime( 2015, 5,1 ) },
        new TestModel1(){ Id = 12, Name = "Tester12", Date = new DateTime( 2015, 5,2 ) },
        new TestModel1(){ Id = 13, Name = "Tester13", Date = new DateTime( 2015, 5,3 ) },
        new TestModel1(){ Id = 14, Name = "Tester14", Date = new DateTime( 2015, 5,4 ) },
        new TestModel1(){ Id = 15, Name = "Tester15", Date = new DateTime( 2015, 5,5 ) },
    }.ToPage(1, 2);

    return View(testPage);

Add the model to the cshtml

@Model Page<TestModel1>

And add the Html.Pager()

@Html.Pager(Model)

This will create an pager with the default settings. You can change the settings of the pager, by use the PagerOptions object.

@Html.Pager(Model, new PagerOptions()
    {
        UrlDisable = true
    })

For the full list of all the parameters of PagerOptions, check here.

To change the order of the items of the pager. You only need to change the parameter ItemShowOrder

@Html.Pager(Model, new PagerOptions()
    {
        ItemShowOrder = new ItemShow[] { ItemShow.FirstItem, ItemShow.PagesItems, ItemShow.LastItem }
    })

For more information about the ItemShow items and examples, check here.

To change the text of the pager, check here.

⚠️ **GitHub.com Fallback** ⚠️