Merge pull request #240 from sosedoff/paginate-remember-sort-order
Remember sort column and order for pagination
This commit is contained in:
commit
03d3c35a86
File diff suppressed because one or more lines are too long
@ -271,10 +271,10 @@ function buildTable(results, sortColumn, sortOrder, options) {
|
|||||||
|
|
||||||
results.columns.forEach(function(col) {
|
results.columns.forEach(function(col) {
|
||||||
if (col === sortColumn) {
|
if (col === sortColumn) {
|
||||||
cols += "<th class='active' data='" + col + "'" + "data-sort-order=" + sortOrder + ">" + col + " " + sortArrow(sortOrder) + "</th>";
|
cols += "<th class='active' data-name='" + col + "'" + "data-order=" + sortOrder + ">" + col + " " + sortArrow(sortOrder) + "</th>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cols += "<th data='" + col + "'>" + col + "</th>";
|
cols += "<th data-name='" + col + "'>" + col + "</th>";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -467,6 +467,19 @@ function showTableContent(sortColumn, sortOrder) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showPaginatedTableContent() {
|
||||||
|
var activeColumn = $("#results th.active");
|
||||||
|
var sortColumn = null;
|
||||||
|
var sortOrder = null;
|
||||||
|
|
||||||
|
if (activeColumn.length) {
|
||||||
|
sortColumn = activeColumn.data("name");
|
||||||
|
sortOrder = activeColumn.data("order");
|
||||||
|
}
|
||||||
|
|
||||||
|
showTableContent(sortColumn, sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
function showTableStructure() {
|
function showTableStructure() {
|
||||||
var name = getCurrentObject().name;
|
var name = getCurrentObject().name;
|
||||||
|
|
||||||
@ -480,8 +493,6 @@ function showTableStructure() {
|
|||||||
$("#input").hide();
|
$("#input").hide();
|
||||||
$("#body").prop("class", "full");
|
$("#body").prop("class", "full");
|
||||||
|
|
||||||
console.log(getCurrentObject());
|
|
||||||
|
|
||||||
getTableStructure(name, { type: getCurrentObject().type }, function(data) {
|
getTableStructure(name, { type: getCurrentObject().type }, function(data) {
|
||||||
buildTable(data);
|
buildTable(data);
|
||||||
$("#results").addClass("no-crop");
|
$("#results").addClass("no-crop");
|
||||||
@ -863,21 +874,13 @@ $(document).ready(function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
$("#results").on("click", "th", function(e) {
|
$("#results").on("click", "th", function(e) {
|
||||||
var sortColumn = this.attributes['data'].value;
|
if (!$("#table_content").hasClass("selected")) return;
|
||||||
var contentTab = $('#table_content').hasClass('selected');
|
|
||||||
|
|
||||||
if (!contentTab) {
|
var sortColumn = $(this).data("name");
|
||||||
return;
|
var sortOrder = $(this).data("order") === "ASC" ? "DESC" : "ASC";
|
||||||
}
|
|
||||||
|
|
||||||
if (this.dataset.sortOrder === "ASC") {
|
$(this).data("order", sortOrder);
|
||||||
this.dataset.sortOrder = "DESC"
|
showTableContent(sortColumn, sortOrder);
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.dataset.sortOrder = "ASC"
|
|
||||||
}
|
|
||||||
|
|
||||||
showTableContent(sortColumn, this.dataset.sortOrder);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#results").on("dblclick", "td > div", function() {
|
$("#results").on("dblclick", "td > div", function() {
|
||||||
@ -952,7 +955,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
if (total > current) {
|
if (total > current) {
|
||||||
$(".current-page").data("page", current + 1);
|
$(".current-page").data("page", current + 1);
|
||||||
showTableContent();
|
showPaginatedTableContent();
|
||||||
|
|
||||||
if (current + 1 == total) {
|
if (current + 1 == total) {
|
||||||
$(this).prop("disabled", "disabled");
|
$(this).prop("disabled", "disabled");
|
||||||
@ -970,7 +973,7 @@ $(document).ready(function() {
|
|||||||
if (current > 1) {
|
if (current > 1) {
|
||||||
$(".current-page").data("page", current - 1);
|
$(".current-page").data("page", current - 1);
|
||||||
$(".next-page").prop("disabled", "");
|
$(".next-page").prop("disabled", "");
|
||||||
showTableContent();
|
showPaginatedTableContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current == 1) {
|
if (current == 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user