meta info
- Title: Paging TagHelper Json Settings
- Keywords: asp.net-core, taghelpers, paging, control, pagination, json, attributes
- Description: Json settings of PagingTagHelper for Asp.Net Core.
- Author: Ziya Mollamahmut
- Date: 08-Aug-2020
- Image: https://github.com/LazZiya/Docs/raw/master/LazZiya.TagHelpers/v5.0/images/lazziya-tagheleprs-logo.png
- Image-alt: LazZiya.TagHelpers Logo
- Version: v5.0
All settings of PagingTagHelper
can be done via appSettings.json
. This settings can be applied to all paging controls or specific ones. This provides a flexibility in controlling the paging controls and offers a clean html on the other hand.
Sample Json settings for PagingTagHelper
{
"lazziya": {
"pagingTagHelper": {
"default": {
"show-first-last": true,
"show-prev-next": true,
"show-page-size-nav": true,
"show-total-pages": true,
"show-total-records": true,
}
}
}
}
If the name of the settings group is default
it will be applied to all paging controls unless a different settings name is specified in the paging control.
For example, below paging controls both will use the default
settings from json:
<paging page-no="Model.PageNo"
page-size="Model.PageSize"
total-records="Model.TotalRecords">
</paging>
<paging page-no="Model.PageNo"
page-size="Model.PageSize"
total-records="Model.TotalRecords"
json-settings="default">
</paging>
It is possible to specify different settings groups for different paging controls. For example below we defined two settings basic
and custom
:
{
"lazziya": {
"pagingTagHelper": {
"basic": {
"show-first-last": true,
"max-displayed-pages": 7,
"class-active-page": "disabled"
},
"custom": {
"show-first-last": true,
"show-prev-next": true,
"show-gap": true,
"max-displayed-pages": 2,
"text-first": "go first",
"text-last": "go last",
"text-previous": "one step back",
"text-next": "one step forward",
"class-paging-control": "pagination pagination-lg"
}
}
}
}
And the relevant paging controls:
<!-- basic settings -->
<paging page-no="Model.PageNo"
page-size="Model.PageSize"
total-records="Model.TotalRecords"
settings-json="basic">
</paging>
<!-- custom settings -->
<paging page-no="Model.PageNo"
page-size="Model.PageSize"
total-records="Model.TotalRecords"
settings-json="custom">
</paging>
Notice: Paging control is configured to use the default settings even if it not defined in
appSettings.json
, so it is not necessary to use json for the default settings.
All json settings with default values in one shot:
{
"lazziya": {
"pagingTagHelper": {
"default": {
"number-system": "default",
"max-displayed-pages": 10,
"page-size-dropdown-items": "10-25-50",
"query-string-key-page-no": "p",
"query-string-key-page-size": "s",
"show-gap": true,
"show-first-last": true,
"show-prev-next": true,
"show-page-size-nav": true,
"show-total-pages": true,
"show-total-records": true,
"text-page-size": "",
"text-first": "«",
"text-last": "»",
"text-previous": "‹",
"text-next": "›",
"text-total-pages": "pages",
"text-total-records": "records",
"sr-text-first": "First",
"sr-text-last": "Last",
"sr-text-previous": "Previous",
"sr-text-next": "Next",
"class": "row",
"class-info-div": "col-1",
"class-page-size-div": "col-1",
"class-paging-control-div": "col-10",
"class-paging-control": "pagination",
"class-active-page": "active",
"class-disabled-jumping-button": "disabled",
"class-total-pages": "badge badge-light",
"class-total-records": "badge badge-dark"
}
}
}
}