none
SharePoint 2013 - Intercept Modal Call to Set Height RRS feed

  • Question

  • I have a list webpart on a custom page, and I have the Open in Dialog enabled.

    How would I go about intercepting the standard SP modal call in order to pass a height value? My modal window is way bigger than it needs to be!

    thank you!

    Monday, February 13, 2017 4:03 PM

Answers

  • Hi,

    Here is the solution for your reference.

    http://sharepoint.stackexchange.com/questions/150222/increase-width-for-form-modal-dialog

    /*
        Overrides SP function OpenPopUpPageWithDialogOptions to allow extended width dialogs.
        This function is used when Launch forms in a dialog setting is set to Yes.
        Custom css rules are also required on form to adjust width.
    */
    ExecuteOrDelayUntilScriptLoaded(
        function() {
            var base_OpenPopUpPageWithDialogOptions = OpenPopUpPageWithDialogOptions;
            OpenPopUpPageWithDialogOptions = function () {
                //arguments[0] is the options argument for SP.UI.ModalDialog.showModalDialog:
                //https://msdn.microsoft.com/en-us/library/office/ff410058(v=office.14).aspx
                if (arguments[0]) {
                    if (!arguments[0].width) {
                        //If window size is less than 1200px, dialog size will still fit into the window.
                        arguments[0].width = 1200;
                    }
                }
    
                return base_OpenPopUpPageWithDialogOptions.apply(this, arguments);
            }
        },
        "core.js"
    );
    
    
    /* Dialog form */
    html.ms-dialog #onetIDListForm {
        width: 100%; }
        /* Dialog form fields */
        html.ms-dialog #onetIDListForm .ms-formbody { 
            width: 100%; }

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Franco667 Tuesday, February 14, 2017 5:32 PM
    Tuesday, February 14, 2017 6:34 AM

All replies

  • Hi,

    Here is the solution for your reference.

    http://sharepoint.stackexchange.com/questions/150222/increase-width-for-form-modal-dialog

    /*
        Overrides SP function OpenPopUpPageWithDialogOptions to allow extended width dialogs.
        This function is used when Launch forms in a dialog setting is set to Yes.
        Custom css rules are also required on form to adjust width.
    */
    ExecuteOrDelayUntilScriptLoaded(
        function() {
            var base_OpenPopUpPageWithDialogOptions = OpenPopUpPageWithDialogOptions;
            OpenPopUpPageWithDialogOptions = function () {
                //arguments[0] is the options argument for SP.UI.ModalDialog.showModalDialog:
                //https://msdn.microsoft.com/en-us/library/office/ff410058(v=office.14).aspx
                if (arguments[0]) {
                    if (!arguments[0].width) {
                        //If window size is less than 1200px, dialog size will still fit into the window.
                        arguments[0].width = 1200;
                    }
                }
    
                return base_OpenPopUpPageWithDialogOptions.apply(this, arguments);
            }
        },
        "core.js"
    );
    
    
    /* Dialog form */
    html.ms-dialog #onetIDListForm {
        width: 100%; }
        /* Dialog form fields */
        html.ms-dialog #onetIDListForm .ms-formbody { 
            width: 100%; }

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Franco667 Tuesday, February 14, 2017 5:32 PM
    Tuesday, February 14, 2017 6:34 AM
  • Thank you.

    I don't know how I had not found that thread previously!

    I modified the parameter to change height, and not width.

    Also i did not need the bit of CSS he says is required at the end. Weird.

    Tuesday, February 14, 2017 5:32 PM