Formulario modal

I am using a modal form that UPDATES a record in the grid. the modal form gets opened through an actionbar link. i want to refresh the grid after i update the record. any help would be greatly appreciated. Can anyone help me? I can’t find a solution.

Estoy usando un formulario modal que actualiza un registro en la cuadrícula. El formulario modal se abre mediante un enlace de la barra de acciones. Quiero actualizar la cuadrícula después de actualizar el registro.Alguien puede ayudarme, no le encuentro la solucion.

Hi gorini,

You can refresh the grid after closing the modal form by adding this JavaScript in your modal form’s onAfterUpdate event(or onAfterInsert if applicable):

// In the modal form’s onAfterUpdate event:
sc_ajax_javascript(“location.reload();”);

Or if you want a smoother approach without full page reload, use this in the modal form’s onAfterUpdate PHP event:

Another option — in your grid application , add this JavaScript in the onScriptInit event to detect when the modal closes:
// Listen for modal close and refresh
window.addEventListener(‘message’, function(e) {
if (e.data === ‘refresh_grid’) {
location.reload();
}
});

Then in your modal form’s onAfterUpdate :

sc_ajax_javascript(“parent.postMessage(‘refresh_grid’, ‘*’);”);

The parent.postMessage approach is the cleanest — it only refreshes when the record is actually updated, not when the modal is just closed.

Hope this helps!

Hi!

Thank you for taking the time to reply.
I found your comment very helpful.
Best regards