Skip to content

fix: DataTables in iframe modals shows 0 rows on initial load - #1794

Open
marcusegger wants to merge 1 commit into
pixl8:stablefrom
marcusegger:fix/iframe-modal-datatable-redraw
Open

fix: DataTables in iframe modals shows 0 rows on initial load#1794
marcusegger wants to merge 1 commit into
pixl8:stablefrom
marcusegger:fix/iframe-modal-datatable-redraw

Conversation

@marcusegger

Copy link
Copy Markdown
Contributor

Problem

When a PresideIframeModal is opened (e.g. when managing a one-to-many
relationship via manageOneToManyRecords), any DataTables grid inside the
iframe renders 0 rows on initial load despite a successful AJAX response.

The root cause: Preside wraps the iframe in <div style="display:none;">
during setup. DataTables initialises and fires its first AJAX request while
the container is still hidden. Since column dimensions are zero at that
point, the returned rows are not rendered.

The issue manifests in modern Chromium-based browsers and is observable
whenever a one-to-many listing is opened as an iframe modal in the Preside
admin.

Workaround (before this fix): typing any character into the search field
and deleting it triggers a redraw and the rows appear.

Fix

Bind fnDraw() to the shown.bs.modal Bootstrap event so that all
object-listing-table DataTables inside the iframe redraw once the modal
animation has completed and the container has proper dimensions.

The existing onShow callback behaviour is preserved.

Affected versions

This issue affects older Preside CMS versions as well and the fix should
be backported accordingly.

@CLAassistant

CLAassistant commented Jun 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

DataTables grids inside PresideIframeModal render 0 rows on initial
load because the iframe container is hidden (display:none) during
DataTables initialisation. Column dimensions are zero at that point,
causing the first AJAX response to be discarded without rendering.

Binding fnDraw() to the shown.bs.modal event ensures the grid redraws
once the modal is fully visible and dimensions are available.

This fix is relevant to older Preside CMS versions as well and should
be backported accordingly.
@marcusegger
marcusegger force-pushed the fix/iframe-modal-datatable-redraw branch from 761c99a to 8ccd45e Compare June 11, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants