Question

So I am using the Upload.aspx for doc lib with GUID in order to have Upload at a custom spot on a page. I think its the edit form that pops up right after you upload a document to add the metadata. This is great and what I need, however there is one little piece I need some help with. If I set the options for the dialog I am using with the Upload.aspx the width and height stick for the edit form that pops open after and either way it looks bad. I either make a ridiculously large dialog for the upload to accomodate the edit, or visa versa.

So I am guessing there is a way to handle that in the callback, just not really sure.

Here is basically what I am calling from an onclick:

function openDialog() {
   var dialogOptions = SP.UI.$create_DialogOptions();
   dialogOptions.url = "server/site/_layouts/Upload.aspx?List={GUID}&IsDlg=1";
   dialogOptions.width = 700  //works for the upload not for the edit
   dialogOptions.height = 185 //same as above; works for the upload
   dialogOptions.title = "My Title"
   dialogOptions.dialogReturnValueCallback = Function.createDelegate(null, CloseCallBack);
   SP.UI.ModalDialog.showModalDialog(dialogOptions); }

function CloseCallBack (result, returnValue) {
     if (result == SP.UI.DialogResult.OK) {
         // logic
     } else {
        // logic 
     }

Is there someway to remedy this? thanks as always for you help guys! always appreciated.

Was it helpful?

Solution

So what you want to do is to change the size of the dialog when the upload.aspx is closed. Try this code

ExecuteOrDelayUntilScriptLoaded(function () {

 var dlg = window.parent.SP.UI.ModalDialog.get_childDialog();
 dlg.$Q_0(800, 800); //width, height

}, "sp.ui.dialog.js");

Also, if you want to size the dialog automatically without specifying the height and width, use this:

ExecuteOrDelayUntilScriptLoaded(function () {

    //calling autoSize method will extend modal dialog beyond the size of the page
    SP.UI.ModalDialog.get_childDialog().autoSize();
    //calling this obfuscated method will trim the dialog back within the page boundaries.
    SP.UI.ModalDialog.get_childDialog().$2B_0();

}, "sp.ui.dialog.js");
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top