Discussion
Pegasystems Inc.
US
Last activity: 3 Jul 2024 14:49 EDT
How to update the total count when filtering the columns of an optimized table
There is no easy way on the server to update the pxResultCount property when applying a filter on an optimized table because the filtering is done at runtime and does not impact the data page itself
This document explains how to update the total result count when applying a filter by running a javascript function everytime the table is updated. This count is available in some of the grid context and some custom JS is required to achieve this functionality
Note that this was tested on 8.7 and uses some not public context that might change with a new platform upgrade
The attached ruleset showcase a demo using the MyWorkList page available with Theme-Cosmos
1/ Create a new section that will include the custom code - this section will be loaded only when the table is loaded
Note that the selector to update the count will need to be tweaked - you can add a helper class on the display Text - in the demo, I am looking the elements by the section name and the format of the display text.
Here is the code snippet
<script>
pega.u.d.attachOnload (function() {
var gridEl = document.getElementById("PEGA_GRID_CONTENT");
if(gridEl && pega.ui.TemplateEngine && pega.ui.TemplateEngine.getClientDataProvider()) {
var dp_name = gridEl.getAttribute("pl_prop").replace(".pxResults","");
var tbl = pega.ui.TemplateEngine.getClientDataProvider().trackedPropertiesList[dp_name];
if(tbl && tbl.$pxFilters) {
var count = Object.values(tbl.$pxFilters)[0].$pxSize;
if(count) {
/* You will need to adjust this selector to locate the element showing the count */
var el = document.querySelector("div[node_name='SearchResults'] .table_search");
if(el) el.text = count;
}
}
}
}, true);
</script>
2/ Add the custom section after the optimized table - make sure that the table has filtering enabled on the column
Here is a demo of the functionality
***Edited by Moderator Marije to add DKS Capability tags***