pagination trigger data fetch & load
This commit is contained in:
parent
014b30c3ec
commit
4c0928e10c
@ -1,14 +1,9 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import requests
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db.models import Subquery
|
|
||||||
from django.db.utils import IntegrityError
|
|
||||||
from django_filters import rest_framework as rest_filters
|
from django_filters import rest_framework as rest_filters
|
||||||
from rest_framework import status, permissions, filters, generics
|
from rest_framework import permissions, filters, generics
|
||||||
from rest_framework.response import Response
|
|
||||||
from rest_framework.pagination import PageNumberPagination
|
from rest_framework.pagination import PageNumberPagination
|
||||||
from rest_framework.authentication import SessionAuthentication, TokenAuthentication
|
from rest_framework.authentication import SessionAuthentication, TokenAuthentication
|
||||||
from rest_framework.parsers import MultiPartParser, FormParser
|
from rest_framework.parsers import MultiPartParser, FormParser
|
||||||
|
@ -35,6 +35,7 @@ function initializeDataTable(tableId, columns) {
|
|||||||
...columns
|
...columns
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
bindTablePagination(tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -100,10 +101,24 @@ async function loadTableData(tableId, url, method) {
|
|||||||
|
|
||||||
// region Pagination
|
// region Pagination
|
||||||
|
|
||||||
function bindTablePagination(tableId) { // TODO:
|
function bindTablePagination(tableId) {
|
||||||
let $paginationArea = $("#subTable").closest('.js-tableBody').siblings('.js-tableControls').find('.pagination');
|
let $paginationArea = $("#subTable").closest('.js-tableBody').siblings('.js-tableControls').find('.pagination');
|
||||||
$paginationArea.on("click", ".page-link", function() {
|
$paginationArea.on("click", ".page-link", function() {
|
||||||
|
let currentPage = $paginationArea.data("page");
|
||||||
|
let wantedPage;
|
||||||
|
|
||||||
|
if ($(this).hasClass("page-prev")) {
|
||||||
|
wantedPage = currentPage - 1;
|
||||||
|
}
|
||||||
|
else if ($(this).hasClass("page-next")) {
|
||||||
|
wantedPage = currentPage + 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wantedPage = $(this).attr("data-page")
|
||||||
|
}
|
||||||
|
|
||||||
|
setTableFilter(tableId, "page", wantedPage);
|
||||||
|
$(tableId).trigger("doDataLoad");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +129,7 @@ function fixTablePagination(tableId) {
|
|||||||
setTableFilter(tableId, "page", 1);
|
setTableFilter(tableId, "page", 1);
|
||||||
}
|
}
|
||||||
if (!("page_size" in filters)) {
|
if (!("page_size" in filters)) {
|
||||||
setTableFilter(tableId, "page_size", 15) // TODO: shouldn't be hard coded
|
setTableFilter(tableId, "page_size", 1) // TODO: shouldn't be hard coded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ $(document).on("selectedServerChange", async function() {
|
|||||||
await loadSubscriptionData();
|
await loadSubscriptionData();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("doLoadSubscriptions", async function() {
|
$(subTableId).on("doDataLoad", async function() {
|
||||||
await loadSubscriptionData();
|
await loadSubscriptionData();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user