I created a custom Ribbon button to generate a report in excel for my external lists. When I click on the ribbon button, A modal pop up is displayed. I want to auto close the modal popup after my report has been generated in excel.
This is what I am doing in order to achieve it,
<CommandUIHandler Command="ExportToExcel" CommandAction="javascript:
function CloseCallback()
{
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel);
}
var ctx = GetCurrentCtx();
var listName =ctx.ListTitle;
var url = $(location).attr('href');
var currentView = $('[id*=\'ListTitleViewSelectorMenu\'] span:first').text();
var options = {url: L_Menu_BaseUrl + '/_layouts/CustomRibbon/ExportExternalList.aspx?list=' + listName + '&view=' + currentView + '&url=' + url,
title: 'Generating Excel!',
allowMaximize: false,
showClose: true,
width: 300,
height: 100
};
SP.UI.ModalDialog.showModalDialog(options);
setTimeout(function() { CloseCallback(); }, 10000);
"/>
</CommandUIHandlers>
My Issue is: The modal popup opens for like 10 seconds and then disappears. My report in excel is not generated. Not sure what I am missing here.
Any help would be much appreciated.