none
SP.UI.ModalDialog Methods - Refresh parent Issue RRS feed

  • Question

  • Hi,

    I have a list (PARENT) that has a field which is a lookup to another list (CHILD).  I have enabled "Allow Multiple Values" onthe lookup field.

    I create a custom form for parent to add a "NEW" button next to the CHILD field, which opens a dialog to add a new Child item so that the user doesnt have to leave parent form to add new data to Child if it doesnt exist.

    Now this all works great, and the parent refreshes when i close my dialog.  But the lookup field doesnt get the new value i captured, i have to close the form and reopen and the new field value is available :-(  This only seems to be the case if the lookup allows multiple, if it doesnt, then it renders as a dropdown and it refreshes on modal close.

    I hope this makes sense.

    here is my meaty code:

    <a href="#" onclick="OpenDialog('Add New Supplier','/International/Lists/mE%20Supplier/NewForm2.aspx');">GO</a>										
    
    
    
    <script>
    //Using the DialogOptions class. Added by Warren Patterson
    function OpenDialog(dtitle,url) {
    
     var options = 
     {
            url: url,
            allowMaximize: true,
            showClose: true,
            title: dtitle,
            dialogReturnValueCallback: function(dialogResult) 
            { 
              SP.UI.ModalDialog.RefreshPage(dialogResult) 
            }
     }
    SP.UI.ModalDialog.showModalDialog(options);
    }
    </script>

    Thanks 

    Warren

    Thursday, August 30, 2012 3:05 PM

All replies

  • Hi Chunkyfeather,

    You can use the following code.

    <script type="text/ecmascript"> var options; function openModalDialog() { options = SP.UI.$create_DialogOptions(); options.width = 300; options.height = 100; options.url = SP.Utilities.Utility.getLayoutsPageUrl('customdialog.htm' ); options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback); SP.UI.ModalDialog.showModalDialog(options); } function CloseCallback(result, target) { location.reload(true); } </script>


    Please refer to the following link.

    http://antoniolanaro.blogspot.com/2011/04/open-sharepoint-2010-modal-dialog-and.html

    Thanks,

    Jack


    Monday, September 3, 2012 2:30 AM
    Moderator
  • Hi ChunkyFeather,

    i think you can do this without the use of code. First is just go to the NewForm.aspx of your parent list. next add a List Web Part in that NewForm.aspx and select your child list in the selection of all the list available. and there you go save the NewForm.aspx and you would be able to achieve what you want.

    Let me know if this helps or you need more details see below for the result

    ranjoe

    Monday, September 3, 2012 7:14 AM
  • Hi Jack,

    I tried your solution already, location.reload will cause entire page to reload and I will lose any data typed in other fields.

    :-(

    Any other ideas?

    Thanks

    Warren


    Monday, September 3, 2012 8:06 AM
  • Hi Chunkyfeather,

    If you don't want location.reload, you can have a try the following code.

    function NewItemDialog(url, title) {
            var options = {
                url: url,
                width: 900,
                height: 700,
                title: title,
                dialogReturnValueCallback: DialogCallback
            };
            SP.UI.ModalDialog.showModalDialog(options);
        }
    function DialogCallback(dialogResult, returnValue) {
              if (returnValue == "1") {
                var meesageId = SP.UI.Notify.addNotification("Loading", false);
                SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
            }
          
        }

    Thanks,

    Jack

    Tuesday, September 4, 2012 3:16 AM
    Moderator
  • Hi Jack,

    Thanks for the reply, but as you can see from my first post, I already tried that :-(

    It doesnt refresh the Multi-Select, it refreshes if its a dropdown (lookup field with only one choice allowed), but not when field is lookup with multi-select enabled.

    This is so frustrating and seems like it should be any easy thing to get around.

    Thanks

    Warren

    Tuesday, September 4, 2012 12:14 PM