I have used JS to create cascading filter from one lookup selection to another. However, after filtering the results keep the paginated pages and returns empty pages. Only the page that has results will show.
I have also turned off pagination by increasing the page size (2000), but this causes very long load times as all data needs to be filtered and then returned.
Is there a way to remove empty pages, move the results to page one, or improve the load time of no pagination?
var selectedProject;
var selectedProjectId;
$(document).ready(function() {
$("#yourproject").change(onPrimaryChange);
$("#yourproject").change();
});
function onPrimaryChange() {
let list = $("#yourcompany_lookupmodal")
.find(".entity-lookup")
.find(".entity-grid")
.eq(0);
let list2 = $("#yourproject_lookupmodal")
.find(".entity-lookup")
.find(".entity-grid")
.eq(0);
// Find the selected row
var selectedCompany = list2.find("table tbody > tr.selected");
// Get the value of the desired column
selectedProject = selectedCompany.find('td[data-attribute="replica_id"]').attr("data-value");
selectedProjectId = selectedCompany.find('td[data-attribute="Id"]').attr("data-value");
localStorage.setItem("selectedProjectId", selectedProjectId);
list.on("loaded", function() {
var projectid = selectedProject;
console.log("projectid : " + projectid);
list.find("table tbody > tr").each(function() {
var tr = $(this);
var projectidOnly = $(tr).find('td[data-attribute="projectid"]').attr("data-value");
if (projectidOnly != projectid) {
tr.remove();
}
});
});
}