0

I have a SharePoint list. And there are 2 views in this list named 'View 1' and 'View 2'. I've set 'Launch forms in a dialog' option to 'Yes' in list settings.

I'm editing the list by clicking on 'edit this list'. See below screenshot:

enter image description here

Now when I click on 'Item 1' as shown in above picture, the below dialog box opens:

enter image description here

What I want is to go to bottom of this dialog box on click of 'Item 1' or 'Items 2' and so on and only for 'View 1' and not for 'View 2'.

I tried adding below script on the edit form but it didn't work:

$(window).load(function ()
{
    var $contents = $("iframe").contents();
    $contents.scrollTop($contents.height());
});

Any suggestions how to achieve this ?

3 Answers 3

1

hope this serves your need. enter image description here

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
    var scrolled = 0;
    $(document).ready(function() {

        scrolled = scrolled + 400;

        jQuery(".ms-core-overlay").animate({
            scrollTop: scrolled
        });
    });
</script>

I did this work around from this link.. http://jsfiddle.net/xEFq5/10/

5
  • Thanks a lot. This works, but it is scrolling to bottom for both the views. Any idea how to restrict it for only one view ? Commented Jan 2, 2017 at 6:33
  • can you explain how you are creating views? out of box views or designer views? Commented Jan 2, 2017 at 7:33
  • Both are out of the box views. Commented Jan 2, 2017 at 8:11
  • I figured it out. See my answer. The code wasn't displayed properly in the comment section so I added it as an answer. Thanks :) Thanks :) Commented Jan 2, 2017 at 8:45
  • it's great ...... :) Commented Jan 2, 2017 at 9:01
0

can you please try this sharepoint UI dialog using javascript code by giving particular Url in place of options.url

<script type="text/javascript">
    $(document).ready(function() {
        OpenAssetPortalBrowserDialog();

    });

    function OpenAssetPortalBrowserDialog() {

            var clientContext = new SP.ClientContext(_spPageContextInfo.siteServerRelativeUrl);
            Web = clientContext.get_web();
            clientContext.load(Web);
            clientContext.executeQueryAsync(function() {
                var options = SP.UI.$create_DialogOptions();
                options.url = "Give your URL Here";
                options.dialogReturnValueCallback = Function.createDelegate(this, CloseAssetPortalBrowserCallback);
                SP.UI.ModalDialog.showModalDialog(options);
            }, function() {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
            });

            function CloseAssetPortalBrowserCallback(result, target) {
                // to do on popup close

            }
</script>
4
  • Where should I put this code ? Also I don't see any code to go to bottom of the page. @Pradeep Kumar Commented Dec 30, 2016 at 6:41
  • create a custom editform.aspx for your view from designer and give your page url in options.url-section Commented Dec 30, 2016 at 6:56
  • this code is only to show custom dialog not for to go to the bottom of page.. Commented Dec 30, 2016 at 7:02
  • This doesn't serve my purpose, it'll just open a dialog box on page load. I think I didn't convey my purpose well. I've now edited the question with screenshots explaining my requirement in detail. Commented Dec 30, 2016 at 10:44
0

The below is the complete answer:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
    var scrolled = 0;
    $(document).ready(function() {
        var editItemURL = window.location.href;
        var viewURL1= "URL of the view for which you want to scroll to bottom";
        if(editItemURL.indexOf(viewURL1) !== -1)
        {
            scrolled = scrolled + 2000;
            jQuery(".ms-core-overlay").animate({
                scrollTop: scrolled
            });
        }
    });
</script>

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.