0

I have a situation where I have a Web Part that contains a SPGridView. In fact I have 3 instances all filtering differently on the same list, all on default.apsx. I have an application page that launches as a Dialog Page for editing a List Item in any of the DataGrids via a link or a spmenufield item.

I need to update all of the WebParts (SPDataGrid) in the Parent page when I update the list item and close the application page. If I use the pager control on the Grid then I can get the update if I go one page one way and then back, but I want to automatically update the grids in the current view without doing that. Also refreshing the page with F5 gets me the updated data.

Note that each SPDataGrid is inside an Update Panel along with the Pager so that I prevent a full postback. It works nicely, but I just can't figure out how to update the dataviews.

Your help is much appreciated as this has broken me for the whole day!

1 Answer 1

1

If you are using the SP modal dialog you can use the RefreshPage callback metod, see the Msdn documentation here: http://msdn.microsoft.com/en-us/library/ff411790(v=office.14).aspx

Like this:

function openDialogEdit(url) {
try {
    var dialogOptions = SP.UI.$create_DialogOptions();
    dialogOptions.url = url;
    dialogOptions.allowMaximise = false;
    dialogOptions.autosize = true;
    dialogOptions.dialogReturnValueCallback = Function.createDelegate(null, editSwitchPlanCallback);
    SP.UI.ModalDialog.showModalDialog(dialogOptions);
}
catch (err) {
    var id = SP.UI.Status.addStatus('Error Editing Switch Program', err.message);
    SP.UI.Status.setStatusPriColor(id, 'Red');
} }

function createSwitchPlanCallback(result, target) {
if (result == SP.UI.DialogResult.OK) {
    SP.UI.Notify.addNotification('New Switch Plan created');
    SP.UI.ModalDialog.RefreshPage(result);
} }
7
  • Thanks, but that will not help. I need to refresh the default.aspx page, not the dialog application page. ideally I want to iterate all Webparts on the default.aspx page and rebind/refresh the view. Apr 30, 2013 at 12:01
  • What do you mean? This will reload the parent page when the modal is closed. Apr 30, 2013 at 12:02
  • Yes, pretty much. Ideally I want to update each webpart (they are all the same web part, just filtered differently) since they have an updatpanel in order to prevent a full postback/refresh of the default.aspx page. The Pager works very nice with the updatepanel. This has me on the bring of insanity. :-| so your suggestions are greatly appreciated. Apr 30, 2013 at 15:35
  • I really do not understand why refreshing the whole page does not solve your issue. It is probably the best you can do, since you can not trigger a refresh of just one updatepanel from .js and that is all you got really. If you do not render some user control in the updatepanels that the user can manually click on to refresh that specific updatepanel Apr 30, 2013 at 15:43
  • A refresh will work, it's just not the desired affect I want. How do I trigger a Refresh on the Default.aspx page as I close an application dialog? Apr 30, 2013 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.