9

In SharePoint 2013, maximize button is missing when click on New item, and there is no way to maximize the modal dialog (opened by standard New or Edit item).

I tried JavaScript method that works on SharePoint 2010

function _maximizeWindow() {
var currentDialog = SP.UI.ModalDialog.get_childDialog();
if (currentDialog != null && !currentDialog.$S_0)
    currentDialog.$z();
}
ExecuteOrDelayUntilScriptLoaded(_maximizeWindow, 'sp.ui.dialog.js');

But this code doesn't work on 2013 version.

Is there any way to maximize modal dialog on SharePoint 2013?

2
  • have you tried "allowMaximize" property of SP.UI.ModalDialog?
    – Garima
    Commented Jan 11, 2014 at 8:47
  • Where can I put allowMaximize? I use standard New item button of SharePoint to open dialog, not customized showModalDialog function. Commented Jan 11, 2014 at 9:52

3 Answers 3

8

The internal names of SP_UI_Dialog has changed in on RTM SP2013 on-premises so you should use:

function _maximizeWindow() {
  var currentDialog = SP.UI.ModalDialog.get_childDialog();
  if (currentDialog != null && !currentDialog.$Q_0) {
      currentDialog.$1Y_0();
  }
}
ExecuteOrDelayUntilScriptLoaded(_maximizeWindow, 'sp.ui.dialog.js');

On the current Office 365 you should use:

function _maximizeWindow() {
  var currentDialog = SP.UI.ModalDialog.get_childDialog();
  if (currentDialog != null && !currentDialog.$Q_0) {
      currentDialog.$1l_0();
  }
}
ExecuteOrDelayUntilScriptLoaded(_maximizeWindow, 'sp.ui.dialog.js');

Here is a guide on how to find the current version:

  1. Get a nicely formatted version of sp.ui.dialog.js. In IE 11 you can do it like this
    1. Open the page with the dialog open
    2. Press F12 to open Developer tools
    3. Select the debugger (tab with bug no sign)
    4. Select sp.ui.dialog.js in the folder dropdown
    5. Turn pretty print on (button with curly braces)
  2. Search for showMaximized
  3. Note the member of this which is assigned a value (on current O365 its $1I_0)
  4. Search for this member
  5. At some point it's used in an if or conditional expression (on current O365 the line is this.$1I_0 && this.$1l_0(null);
  6. The function called is the maximize toggle function. Remember this function
  7. Search for this function (on current O365 its $1l_0)
  8. The first check inside the function (on current O365 the line is if(this.$Q_0) {) is the check for already maximized. Remember the member used in this check
  9. Use the member from bullet 8 in the check and call the function from bullet 6.
7
  • the error Object [object Object] has no method '$1Y_0' is showing on console log and dialog is not maximized. I'm using SP Online 2013 (Office 365), does it matter? Commented Jan 11, 2014 at 18:53
  • 1
    I've updated the answer with Office 365 version and how to find the version for your current version. But as I've seen calling these internal members isn't without problems Commented Jan 11, 2014 at 19:29
  • Thank you, it works now. Disappointing but not surprising with MS, on-premise and online version has different internal names. And it takes extra time to have solutions work both on development and production environment... Commented Jan 12, 2014 at 5:08
  • How do you implement the function to override the OOB working?
    – Remko
    Commented Jan 12, 2014 at 12:52
  • I create a web part and call the function on page ready. Actually in my case, a setTimeOut is needed as dialog gets back to old size after ready, so I must call the function again to maximize the dialog. Commented Jan 12, 2014 at 17:43
0

You can add options to the SP.UI.ModalDialog.showModalDialog(options) method

For example

var options = {
title: "My Dialog Title",
width: 400,
height: 600,
allowMaximize: true,
showMaximized: true,
showClose: true,
url: "/_layouts/DialogPage.aspx" };

SP.UI.ModalDialog.showModalDialog(options);
2
  • 1
    This is how you do it if you control the opening of the dialog, but not for dialogs opened by standard SP Commented Jan 11, 2014 at 16:47
  • Sorry Remko but here I am using standard dialog opener (New item button), so I need something maximizes dialog from inside the form Commented Jan 11, 2014 at 18:31
-1

Its the SP2010 code and the example shows how to maximize dialog window. You may refer it for SP2013 with the latest changes.

$z function switches the state of the dialog from "normal" to "maximized". The $S_0 variable is set to true when the dialog is already maximized. Checking if this is the case avoids from switching the state of the dialog at each page refresh.

 function maximizeWindow() {
  var currentDialog = SP.UI.ModalDialog.get_childDialog();
  if (currentDialog != null && !currentDialog.$Q_0) {
      currentDialog.$1Y_0();
  }
}

ExecuteOrDelayUntilScriptLoaded(maximizeWindow, 'sp.ui.dialog.js');

Source : http://www.wawawum.com/blog/post/SharePoint-2010-How-to-maximize-a-Modal-Dialog-in-JavaScript.aspx

4
  • Only works with SP2010 the internal names have changed in SP2013 Commented Jan 11, 2014 at 16:46
  • I have updated the answer accordingly.
    – Pushpendra
    Commented Jan 11, 2014 at 17:09
  • @Pushpendra, currentDialog.$S_0 is undefined and error Object [object Object] has no method '$z' occurred when calling currentDialog.$z(). Commented Jan 11, 2014 at 18:36
  • yes...u might get it as Per Jak commented. Its 2010 code, u could refer to the new variables as mentioned by Per Jak.
    – Pushpendra
    Commented Jan 11, 2014 at 18:40

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.