I am new to SharePoint and want to create a list with items which can be expanded/collapsed similar to excel. e.g. In the attached pic I want to hide the test steps and display the entire test case row by default. If the user wants he/she can click and expand to see the test steps.

enter image description here

Any pointers would be appreciated.

  • Hi, Please refer the following link that i came across. May be this could be helpful for you. Link - bitsofsharepoint.com/ExamplePoint/Site/ListExpandTextField.aspx Commented Sep 28, 2016 at 8:14
  • Do I need to change any part of the code (any variable or icon names)? It is not working for me. I have a list in Newsletter style and 2 levels of grouping. And do I need to create buttons and link those? Commented Apr 10, 2020 at 22:42

2 Answers 2


There is no way to expand SharePoint item, without customization. For OOB you can group them together and then see expand/collapse option. To group items together, Click List Ribbon-> Modify View-> Scroll to Grouping-> Select column to Group-> OK


Something very handy that is missing from SharePoint lists when you apply groupping, is the Expand/Collapse all button. Here is a simple js that will expand Level 1 first and then Level 2, but will collapse all at once.

You just need to add a Script Editor web part on the page.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
    var isLevel1Expanded = false;
    function expandAll() {
    $('tbody[id*=titl]').each(function (k, v) {
      var elementName = $(this).attr('id');
      var level1RegEx = /^titl[0-9]*-[0-9]*_$/;
      var level2RegEx = /^titl[0-9]*-[0-9]*_[0-9]*_$/;
      if(elementName.match(level1RegEx) && !isLevel1Expanded){
        //console.log('level 1');
        //isLevel1Expanded = true;
      else if(elementName.match(level2RegEx) && isLevel1Expanded){
                //console.log('level 2');
    isLevel1Expanded = true;
    function collapseAll() {
    isLevel1Expanded = false;
    var expandButton = "<a href='#' onClick="
    +'"' + "this.href='javascript:expandAll()'"
    + '">&nbsp;<img title="Expand all groups" style="border:none;" alt="expand all" src="https://hsdatacloud.sharepoint.com/sites/departments/TechnicalServices/SiteAssets/plus.png"></a>';
    var collapseButton = "<a href='#' onClick="
    +'"' + "this.href='javascript:collapseAll()'"
    + '">&nbsp;<img title="Collapse all groups" style="border:none;" alt="collapse all" src="https://hsdatacloud.sharepoint.com/sites/departments/TechnicalServices/SiteAssets/minus.png"></a>';
    $(document).ready(function () {

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.