0

I am a non-coder. I have a FAQ page which is a list view with Newsletter style. There are 2 levels of grouping used 1. Category 2. Question.

I am looking to add a toggle button or 2 buttons for Expand All and Collapse All. I tried using some codes from net but looks like they either work only with 1 layer of grouping or they do not expand or collapse a partially opened list.

If anyone has a solution for this , please help!

3
  • Coding using Javascript is really easy. To be honest its much easier to use compared to .NET. I really highly suggest try to learn it. Possibilities are endless. I got no problem helping you to start if you want
    – Billy P
    Commented Apr 1, 2020 at 5:02
  • Thanks Billy, yes I am always open to learn new stuff. Kindly help pointing in the right direction. Commented Apr 1, 2020 at 5:11
  • Hi, I would suggest learn first the basic of Javascript once your good with that try learning doing basic like adding list item using Javascript by connecting to Rest API of SharePoint. Feel free to let me know if you got question and I also wanted to know what your level in terms of Javascript
    – Billy P
    Commented Apr 1, 2020 at 5:29

2 Answers 2

0

I suggest using Javascript in creating custom applications. I suggest stay away from server side code and try learning CSOM/JSOM because thats the trend right now.

0

This is almost 5 years late but you can add this into a Script Editor above or below a list view. It will add a + or - to the right of the View menu. Clicking the + will expand groups.

  • You might need to experiment with the jQuery version
  • See the source comments mid way through to see where I got this
  • I have used this in SP2013 and SP2019
<script  src="https://code.jquery.com/jquery-3.7.1.min.js"
  integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
  crossorigin="anonymous"></script>
<script type="text/javascript">

    function expandAll() {

        $("img.ms-commentexpand-icon").click();

    }

    function collapseAll() {

        $("img.ms-commentcollapse-icon").click();

    }

    var expandButton = "<a href='#' onClick="

    +'"' + "this.href='javascript:expandAll()'"

    + '">&nbsp;<img title="expand all groups" style="border:none;" alt="expand all" src="/_layouts/images/advadd.png" width="15" height="15"></a>';

    var collapseButton = "<a href='#' onClick="

    +'"' + "this.href='javascript:collapseAll()'"

    + '">&nbsp;<img title="expand all groups" style="border:none;" alt="collapse all" src="/_layouts/images/advminus.png" width="15" height="15"></a>';

    $(document).ready(function () {

        $(".ms-pivotControl-container").append(expandButton).append(collapseButton);

    });

// Source:  http://www.sharepointdiary.com/2014/07/expand-collapse-all-groups-in-sharepoint-2013-list-view-jquery.html


ExecuteOrDelayUntilScriptLoaded(overrideSurfacePivotCount, 'clienttemplates.js');

function overrideSurfacePivotCount() {
   ClientPivotControl.prototype.SurfacedPivotCount = 10;
};
</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.