none
How collapse as default only certain tasks in the task list RRS feed

  • Question

  • Hello, I know how to collapse all tasks in the task list per default, but it works only on the 1st level, so all 1st level tasks will be collapsed. Is there a way to collapse the 2nd level tasks per default or better, only certain tasks? Thank you.
    Thursday, August 23, 2018 12:25 PM

All replies

  • Hi Karych,

    You could add the code below into content editor web part or script editor web part in the task list page. It will collapse the second level tasks.

    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    
    <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    
    <script type="text/javascript">
    
    function doCollapseTaskList() {
    
     $(".ms-commentcollapse-iconouter > img").each(function(){
    
      $(this).click();
    
     });
    
    }
    
    $(function () {
    
          ExecuteOrDelayUntilScriptLoaded(function () {
    
              if (typeof asyncDeltaManager != "undefined")
    
                asyncDeltaManager.add_endRequest(doCollapseTaskList);
    
              else doCollapseTaskList();
    
          }, "SP.Core.js");
    
    });
    
    </script>


    The result as below:


    There is a similar post:

    https://social.technet.microsoft.com/Forums/office/en-US/51a1ada6-d514-4727-b9a5-6a689b70067e/tasks-with-subtasks-collapse-by-default-sharepoint-2013?forum=sharepointgeneral

    Best regards,

    Sara Fan


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


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Friday, August 24, 2018 3:00 AM
    Moderator
  • Thank you Sara. The structure I should get as a result you've shown is correct. But with this code I get the same result: all 1st level tasks are collapsed and not the 2nd level. Are you sure it's correct?
    Friday, August 24, 2018 9:31 AM
  • Hi Karych,

    Per my test in my SharePoint 2013 environment, if I use the custom code in my previous post, the second level will be collapsed.

    To troubleshoot the issue, you could clear IE cache.

    And switch to other browsers.

    Best regards,

    Sara Fan


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


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, August 27, 2018 10:10 AM
    Moderator
  • Hi Sara,

    I did everything, but it doesn't work. Only the first level for the task list. I tried the different views also. May be some special settings?

    I have SP2013 Fozbdation.

    Thanks

    Karych

    Tuesday, August 28, 2018 8:52 AM
  • Hi Karych,

    To troubleshoot the issue, you could create a new task list to check if the same issue will occur.

    Best regards,

    Sara Fan


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


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Tuesday, September 4, 2018 8:21 AM
    Moderator
  • Hi Karych,

    I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

    If the issue was resolved, you can mark the helpful post as answer to help other community members find the helpful information quickly. 

    Best regards,

    Sara Fan

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


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, September 10, 2018 1:14 AM
    Moderator
  • Hi

    I have similar issue with this. I tried different codes and everthing.

    It doesn't work on any browser.

    Strange thing happened once when i added script on page. Button collapse task list started to work but after refreshing the page it doesnt work anymore. I have cleared the cache.

    my version of IE 11:11.885.17134.0

    Wednesday, July 17, 2019 10:11 AM