Paging funzionante
This commit is contained in:
parent
735801f17b
commit
9c6becc1f0
|
@ -408,17 +408,17 @@
|
|||
<div id="collapseZero" class="collapse"
|
||||
aria-labelledby="headingZero" data-parent="#accordionNav">
|
||||
<div class="card-body p-3 align-self-end text-right">
|
||||
|
||||
<ul class="pagination pagination-sm justify-content-end m-0" id="listPagination2">
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link" href="#" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span></a></li>
|
||||
<ul class="pagination pagination-sm justify-content-end m-0" id="listPagination">
|
||||
<span class="small text-muted pt-2 px-1">Pag. </span>
|
||||
<li class="page-item" id='pagPrecedente'>
|
||||
<a class="page-link" href="#" aria-label="Precedente">
|
||||
<span class="h6 font-weight-bold" aria-hidden="true">«</span></a></li>
|
||||
<li class="page-item"><a class="page-link p-0" href="#">
|
||||
<select class="custom-select custom-select-sm bg-light border-0" id="paginaLista" style="height: 29px; max-width: 180px;">
|
||||
<option value="1">1/3</option><option value="2">2/3</option><option value="3">3/3</option></select></a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Next">
|
||||
<span aria-hidden="true">»</span></a></li>
|
||||
<select class="custom-select custom-select-sm bg-light border-0 " id="paginaLista" style="height: 29px;">
|
||||
<option value="1">1/1</option></select></a></li>
|
||||
<li class="page-item" id='pagSuccessiva'>
|
||||
<a class="page-link" href="#" aria-label="Successiva">
|
||||
<span class="h6 font-weight-bold" aria-hidden="true">»</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
var getJsonQuery;
|
||||
var currStyle = "style1";
|
||||
var currPage = 0;
|
||||
var numeroPagine = 0;
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
@ -230,16 +232,28 @@ $(document).ready(function() {
|
|||
*/
|
||||
|
||||
$('#collapseZero').on('shown.bs.collapse', function () {
|
||||
var numeroPagine = Math.ceil(listarisultati.length/nRisultatiPerPag);
|
||||
console.log("numeroPagine: "+ Math.ceil(listarisultati.length/nRisultatiPerPag));
|
||||
//$("#showLogic").html('<span class="font-weight-bold text-muted">Nascondi</span>');
|
||||
//$("#collapseZero").collapse('hide');
|
||||
$.manageResultList(0, nRisultatiPerPag);
|
||||
})
|
||||
managePage();
|
||||
});
|
||||
|
||||
$('#paginaLista').on('change', function() {
|
||||
newPage = $("#paginaLista")[0].options[$("#paginaLista")[0].selectedIndex].value
|
||||
console.log(newPage);
|
||||
currPage = $("#paginaLista")[0].options[$("#paginaLista")[0].selectedIndex].value;
|
||||
managePage();
|
||||
});
|
||||
|
||||
$('#pagPrecedente').on('click', function() {
|
||||
if (!$(this).hasClass("disabled")){
|
||||
currPage--;
|
||||
$('#paginaLista option[value=' + currPage + ']').prop('selected', true);
|
||||
managePage();
|
||||
};
|
||||
});
|
||||
|
||||
$('#pagSuccessiva').on('click', function() {
|
||||
if (!$(this).hasClass("disabled")){
|
||||
currPage++;
|
||||
$('#paginaLista option[value=' + currPage + ']').prop('selected', true);
|
||||
managePage();
|
||||
};
|
||||
});
|
||||
|
||||
// Evento: modifica dell'unita di ricerca'
|
||||
|
@ -1347,5 +1361,42 @@ $(document).ready(function() {
|
|||
resetContext(claIdNum)
|
||||
}
|
||||
};
|
||||
|
||||
function managePage() {
|
||||
console.log ("currPage: " + currPage);
|
||||
if (currPage == 0){
|
||||
numeroPagine = Math.ceil(listarisultati.length/nRisultatiPerPag);
|
||||
$("#paginaLista option").remove();
|
||||
for (let i = 1; i <= numeroPagine; i++) {
|
||||
$('#paginaLista').append(`<option value="${i}">${i+'/'+numeroPagine}</option>`);
|
||||
};
|
||||
$("#pagPrecedente").addClass("disabled");
|
||||
if (numeroPagine > 1) {
|
||||
$("#pagSuccessiva").removeClass("disabled")
|
||||
} else {
|
||||
$("#pagSuccessiva").addClass("disabled")
|
||||
};
|
||||
currPage = 1;
|
||||
} else {
|
||||
if ((currPage == 1) && (currPage == numeroPagine)) {
|
||||
$("#pagPrecedente").addClass("disabled")
|
||||
$("#pagSuccessiva").addClass("disabled")
|
||||
} else {
|
||||
if (currPage == 1) {
|
||||
$("#pagPrecedente").addClass("disabled")
|
||||
$("#pagSuccessiva").removeClass("disabled")
|
||||
} else {
|
||||
if (currPage == numeroPagine) {
|
||||
$("#pagPrecedente").removeClass("disabled")
|
||||
$("#pagSuccessiva").addClass("disabled")
|
||||
} else {
|
||||
$("#pagPrecedente").removeClass("disabled")
|
||||
$("#pagSuccessiva").removeClass("disabled")
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
$.manageResultList((currPage-1)*nRisultatiPerPag, nRisultatiPerPag);
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue