From 9c30d0c36248c9be7b7127588baf28c021eb6369 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Thu, 30 Apr 2026 01:54:18 +0530 Subject: [PATCH] Add DataTables-compatible reload fallback for invoice draft filter --- app/Views/medical/invoice_med_draft.php | 35 ++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/app/Views/medical/invoice_med_draft.php b/app/Views/medical/invoice_med_draft.php index 45094b2..1a8bcc3 100644 --- a/app/Views/medical/invoice_med_draft.php +++ b/app/Views/medical/invoice_med_draft.php @@ -121,9 +121,42 @@ table.columns(col).search(val).draw(); }); + function reloadInvoiceTable(resetPaging) { + var reset = !!resetPaging; + + if (table && table.ajax && typeof table.ajax.reload === 'function') { + table.ajax.reload(null, reset); + return; + } + + if (table && typeof table.api === 'function') { + var api = table.api(); + if (api && api.ajax && typeof api.ajax.reload === 'function') { + api.ajax.reload(null, reset); + return; + } + if (api && typeof api.draw === 'function') { + api.draw(!reset); + return; + } + } + + if (table && typeof table.draw === 'function') { + table.draw(!reset); + return; + } + + if (table && typeof table.fnDraw === 'function') { + table.fnDraw(); + return; + } + + jQuery(tableId + ' tbody').html('Table refresh failed due to DataTable version mismatch.'); + } + filterForm.on('submit', function (e) { e.preventDefault(); - table.ajax.reload(null, true); + reloadInvoiceTable(true); }); })();