Refresh data grid after closing dialog

Hi, I’m trying to refresh a data grid after closing a dialog. I can perhaps set this as a simple action on a button but I have 2 problems with that: 1-When I choose to “select widget” to refresh, I cannot see the data grid on the main view behind the dialog window so I cant select it. I also need this function to “save and close” the dialog window and submit the form with data. This means, the dialog closes successfully and the new data is created but I must refresh the main page to see the new data line item. I was trying to add CSS to the data grid, something like:

function closeDialog (){
context.getWidget(‘DataGrid_0’).refresh();}

But it doesn’t seem to work. Do I have the right approach here? Thanks!
You can see in the pic that the data is entered and then applied using ‘save’. The dialog closes but the data grid behind does not refresh.
44%20PM

Hi Matt,

You are probably using a QuickAction for opening the dialog, but if you use the javascript API you can easily solve this. The method for opening a dialog takes three arguments (the name of the dialog, a record (or record id to be passed to the dialog) and a set of options). The options-object allows you to specify a callback-function to be invoked when the dialog is closed.

Here’s an example:

// Note I'm passing null for the record here, if you want to edit a record you will need to pass it (or its ID) here instead.
context.openDialog('MyDialog', null, {
   onDone: function() {
        context.getWidget("DataGrid_0").refresh();
   }
});

You can find documentation regarding the client-side API at:

https://apps.appivo.com/apidocs/index.html

We should add to the QuickAction so that it can handle this case too.

Thanks,

/Johan/

1 Like

Thanks, will give this a try and let you know how it goes!

Hey, this worked great, thanks! On to many more tricky little items :slight_smile: