I use subgrid api 'setFilterXml' in form onLoad function , after subgrid data onload with the new filter xml, click the nextPage button, the nextPage button only just could change to '2', and then it will not work and do nothing when I click it again.
When it jump to page 2, and then I click next page again, it will not wok.
Good morning, afternoon, or evening depending on your location! It looks like the issue might be related to how setFilterXml is interacting with pagination in the Subgrid API. When you apply filtering dynamically in the onLoad function, it may refresh the subgrid in a way that disrupts the default paging functionality. Here’s what could be happening: Possible Causes:
Filter Application Resets Paging Context
When setFilterXml is applied, it forces a refresh of the subgrid, which can reset the pagination state, preventing further navigation past page 2.
Subgrid Not Properly Registering Next Page Requests
If filtering occurs too early (before the grid is fully loaded), the system might not correctly register page change requests beyond the first navigation.
Pagination Behavior Conflicts with Data Refresh
After applying setFilterXml, the grid may need explicit handling to ensure pagination continues working after each page change.
Potential API Limitation or Bug
Microsoft occasionally updates the behavior of Power Platform APIs. If this issue appeared after an update, it's worth checking if there’s a known bug or workaround in official documentation.
Possible Fixes: Apply setFilterXml AFTER Subgrid Loads
Instead of setting the filter in onLoad, trigger it after the subgrid data loads using an event like OnDataRefresh.
Manually Refresh the Grid After Paging
Use JavaScript to force a refresh each time the pagination button is clicked:
function refreshSubgridAfterPaging(executionContext) {
var formContext = executionContext.getFormContext();
var subgridControl = formContext.getControl("your_subgrid_name"); if (subgridControl) {
subgridControl.refresh();
}
} Delay Filter Application Using Timeout
If the filter is applied too soon, delaying it may allow the subgrid to maintain correct paging behavior:
setTimeout(function() {
var subgridControl = formContext.getControl("your_subgrid_name");
subgridControl.setFilterXml("<filter><condition attribute='statuscode' operator='eq' value='10000001' /></filter>");
subgridControl.refresh();
}, 1000); Test with Default Pagination First
Before applying the filter, confirm that paging works correctly without setFilterXml. This helps determine whether the issue is related to filtering or an underlying subgrid behavior.
If none of these approaches resolve the issue, consider checking the browser console (F12 → Console) for any JavaScript errors that might indicate an API-related issue.
Please note: I teamed up with CoPilot AI to research and craft the best response to your question! Hope this helps some!
Was this reply helpful?YesNo
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.