Paging TagHelper - Ajax >= v4.0

Ajax Sample : Cultures Table

LCID English Name Native Name
4096 Makhuwa-Meetto Makua
4096 Makhuwa-Meetto (Mozambique) Makua (Umozambiki)
4096 Makonde Chimakonde
4096 Makonde (Tanzania) Chimakonde (Tanzania)
4096 Malagasy Malagasy
4096 Malagasy (Madagascar) Malagasy (Madagasikara)
62 Malay Melayu
2110 Malay (Brunei) Melayu (Brunei)
1086 Malay (Malaysia) Melayu (Malaysia)
4096 Malay (Singapore) Melayu (Singapura)
76 Malayalam മലയാളം
1100 Malayalam (India) മലയാളം (ഇന്ത്യ)
58 Maltese Malti
1082 Maltese (Malta) Malti (Malta)
88 Manipuri মৈতৈলোন্
1112 Manipuri (India) মৈতৈলোন্ (India)
4096 Manx Gaelg
4096 Manx (Isle of Man) Gaelg (Ellan Vannin)
129 Maori te reo Māori
1153 Maori (New Zealand) te reo Māori (Aotearoa)
122 Mapudungun Mapudungun
1146 Mapudungun (Chile) Mapudungun (Chile)
78 Marathi मराठी
1102 Marathi (India) मराठी (भारत)
4096 Masai Maa
4096 Masai (Kenya) Maa (Kenya)
4096 Masai (Tanzania) Maa (Tansania)
4096 Mazanderani مازرونی
4096 Mazanderani (Iran) مازرونی (ایران)
4096 Meru Kĩmĩrũ
4096 Meru (Kenya) Kĩmĩrũ (Kenya)
4096 Metaʼ metaʼ
4096 Metaʼ (Cameroon) metaʼ (Kamalun)
124 Mohawk Kanien’kéha
1148 Mohawk (Mohawk) Kanien'kéha
80 Mongolian монгол
30800 Mongolian монгол
1104 Mongolian (Mongolia) монгол (Монгол)
31824 Mongolian (Traditional Mongolian) ᠮᠣᠩᠭᠣᠤᠯ ᠬᠡᠯᠡ
2128 Mongolian (Traditional Mongolian, China) ᠮᠣᠩᠭᠣᠤᠯ ᠬᠡᠯᠡ (ᠪᠦᠭᠦᠳᠡ ᠨᠠᠢᠷᠠᠮᠳᠠᠬᠤ ᠳᠤᠮᠳᠠᠳᠤ ᠠᠷᠠᠳ ᠣᠯᠣᠰ)
3152 Mongolian (Traditional Mongolian, Mongolia) ᠮᠣᠩᠭᠣᠯ ᠬᠡᠯᠡ (ᠮᠣᠩᠭᠣᠯ ᠣᠯᠣᠰ)
4096 Morisyen kreol morisien
4096 Morisyen (Mauritius) kreol morisien (Moris)
4096 Mundang MUNDAŊ
4096 Mundang (Cameroon) MUNDAŊ (kameruŋ)
4096 Nama Khoekhoegowab
4096 Nama (Namibia) Khoekhoegowab (Namibiab)
97 Nepali नेपाली
2145 Nepali (India) नेपाली (भारत)
1121 Nepali (Nepal) नेपाली (नेपाल)

Setup for ajax

  • Create a div element that will handle the updated the content
    <div class="items"></div>
  • Create a partial view to render in the target area e.g. PagingItemsPartial.cshtml. The partial view model is the same as the page model in out sample PagingAjaxModel.
  • Put the paging taghelper in the partial, currently it supports only "replace" mode for ajax, thats why we have to keep the paging inside the partial, so it will refresh with the partial data accordingly.
  • Use ajax-... attributes to add ajax support to the PagingTagHelper.
  • In the backend, create the relevant handler that will return the partial view via ajax.
  • Add reference to ajax in the Scripts section:
    <script src="https://cdn.jsdelivr.net/npm/jquery-ajax-unobtrusive@3.2.6/dist/jquery.unobtrusive-ajax.min.js"></script>

Sample partial view with Paging control included

            
@model PagingAjaxModel

<table class="table table-striped">
    <thead>
        <tr>
            <th>LCID</th>
            <th>English Name</th>
            <th>Native Name</th>
        </tr>
    </thead>
    <tbody>
        @if (Model.TotalRecords == 0)
        {
            <tr>
                <td colspan="3">No records!</td>
            </tr>
        }
        else
        {
            foreach (var c in Model.CulturesList)
            {
                <tr>
                    <td>@c.LCID</td>
                    <td>@c.EnglishName</td>
                    <td>@c.NativeName</td>
                </tr>
            }
        }
    </tbody>
    <tfoot>
        <tr>
            <td colspan="3">
                <paging page-no="Model.P"
                        page-size="Model.S"
                        total-records="Model.TotalRecords"
                        ajax="true"
                        ajax-url="?handler=AjaxPaging"
                        ajax-update="#items"
                        ajax-loading="#loading-spinner"></paging>
            </td>
        </tr>
    </tfoot>
</table>