Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Farids78's avatar

Search quesry display only results of current pagination

Hi, I have a user table with a search field. If I enter a username on my search field I only get results of the current pagination? How can I get results from the entire table?

I guess that this should be managed somewhere in the code below:

"use strict"; var KTUsersList = function () { var e, t, n, r, o = document.getElementById("kt_table_users"), c = () => { o.querySelectorAll('[data-kt-users-table-filter="delete_row"]').forEach((t => { t.addEventListener("click", (function (t) { t.preventDefault(); const n = t.target.closest("tr"), r = n.querySelectorAll("td")[1].querySelectorAll("a")[1].innerText; Swal.fire({ text: "Are you sure you want to delete " + r + "?", icon: "warning", showCancelButton: !0, buttonsStyling: !1, confirmButtonText: "Yes, delete!", cancelButtonText: "No, cancel", customClass: { confirmButton: "btn fw-bold btn-danger", cancelButton: "btn fw-bold btn-active-light-primary" } }).then((function (t) { t.value ? Swal.fire({ text: "You have deleted " + r + "!.", icon: "success", buttonsStyling: !1, confirmButtonText: "Ok, got it!", customClass: {confirmButton: "btn fw-bold btn-primary"} }).then((function () { e.row($(n)).remove().draw() })).then((function () { a() })) : "cancel" === t.dismiss && Swal.fire({ text: customerName + " was not deleted.", icon: "error", buttonsStyling: !1, confirmButtonText: "Ok, got it!", customClass: {confirmButton: "btn fw-bold btn-primary"} }) })) })) })) }, l = () => { const c = o.querySelectorAll('[type="checkbox"]'); t = document.querySelector('[data-kt-user-table-toolbar="base"]'), n = document.querySelector('[data-kt-user-table-toolbar="selected"]'), r = document.querySelector('[data-kt-user-table-select="selected_count"]'); const s = document.querySelector('[data-kt-user-table-select="delete_selected"]'); c.forEach((e => { e.addEventListener("click", (function () { setTimeout((function () { a() }), 50) })) })), s.addEventListener("click", (function () { Swal.fire({ text: "Are you sure you want to delete selected customers?", icon: "warning", showCancelButton: !0, buttonsStyling: !1, confirmButtonText: "Yes, delete!", cancelButtonText: "No, cancel", customClass: { confirmButton: "btn fw-bold btn-danger", cancelButton: "btn fw-bold btn-active-light-primary" } }).then((function (t) { t.value ? Swal.fire({ text: "You have deleted all selected customers!.", icon: "success", buttonsStyling: !1, confirmButtonText: "Ok, got it!", customClass: {confirmButton: "btn fw-bold btn-primary"} }).then((function () { c.forEach((t => { t.checked && e.row($(t.closest("tbody tr"))).remove().draw() })); o.querySelectorAll('[type="checkbox"]')[0].checked = !1 })).then((function () { a(), l() })) : "cancel" === t.dismiss && Swal.fire({ text: "Selected customers was not deleted.", icon: "error", buttonsStyling: !1, confirmButtonText: "Ok, got it!", customClass: {confirmButton: "btn fw-bold btn-primary"} }) })) })) }; const a = () => { const e = o.querySelectorAll('tbody [type="checkbox"]'); let c = !1, l = 0; e.forEach((e => { e.checked && (c = !0, l++) })), c ? (r.innerHTML = l, t.classList.add("d-none"), n.classList.remove("d-none")) : (t.classList.remove("d-none"), n.classList.add("d-none")) }; return { init: function () { o && (o.querySelectorAll("tbody tr").forEach((e => { const t = e.querySelectorAll("td"), n = t[3].innerText.toLowerCase(); let r = 0, o = "minutes"; n.includes("yesterday") ? (r = 1, o = "days") : n.includes("mins") ? (r = parseInt(n.replace(/\D/g, "")), o = "minutes") : n.includes("hours") ? (r = parseInt(n.replace(/\D/g, "")), o = "hours") : n.includes("days") ? (r = parseInt(n.replace(/\D/g, "")), o = "days") : n.includes("weeks") && (r = parseInt(n.replace(/\D/g, "")), o = "weeks"); const c = moment().subtract(r, o).format(); t[3].setAttribute("data-order", c); const l = moment(t[5].innerHTML, "DD MMM YYYY, LT").format(); t[5].setAttribute("data-order", l) })), (e = $(o).DataTable({ info: true, order: [], pageLength: 25, lengthChange: false, paginate: true, searching: true, columnDefs: [{orderable: false, targets: 0}, {orderable: false, targets: 6}], })).on("draw", (function () { l(), c(), a() })), l(), document.querySelector('[data-kt-user-table-filter="search"]').addEventListener("keyup", (function (t) { e.search(t.target.value).draw() })), document.querySelector('[data-kt-user-table-filter="reset"]').addEventListener("click", (function () { document.querySelector('[data-kt-user-table-filter="form"]').querySelectorAll("select").forEach((e => { $(e).val("").trigger("change") })), e.search("").draw() })), c(), (() => { const t = document.querySelector('[data-kt-user-table-filter="form"]'), n = t.querySelector('[data-kt-user-table-filter="filter"]'), r = t.querySelectorAll("select"); n.addEventListener("click", (function () { var t = ""; r.forEach(((e, n) => { e.value && "" !== e.value && (0 !== n && (t += " "), t += e.value) })), e.search(t).draw() })) })()) } } }(); KTUtil.onDOMContentLoaded((function () { KTUsersList.init() }));

0 likes
4 replies
amitsolanki24_'s avatar

@farids78 Type your code in proper format

like this

use 3 backticks at the start and 3 backticks at the end anything in between will be formatted.

Snapey's avatar

You would need to send the search term to the server and let it return matching records

Farids78's avatar

@Snapey Yes, I just need to find for instance all users of the data table. Currently if "Marc" is not listed on page 1 I won't have any result If I have a user "Marc" on page 2 and if I search while I'm positionning on page 2, then I will have a result.

To resume the results are currently limited to the current pagination.

Please or to participate in this conversation.