Question

I'm currently using the following piece of code to hide all the subtasks from my view.

<script
      src="https://code.jquery.com/jquery-3.2.1.min.js"
      integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
      crossorigin="anonymous"></script>

<script>
jQuery(document).ready(function(){
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', run);
});

function run(){
    jQuery('div[class="ms-vb  itx"]').find('span[style]').each(function(){
        var left = Number(jQuery(this).css('margin-left').replace("px",""));
        if(left>20){
            jQuery(this).parent().parent().parent().remove();//hide();
        }
    });
}
</script>

I'm now trying to convert that list of parent tasks into a Gantt view however it still displays the subtasks inside said Gantt view and i've had no success trying to hide them.

Any help hiding the subtasks on the Gantt view is greatly appreciated.

I

Was it helpful?

Solution 2

So for anyone else who happens to randomly need this solution, this is how i'm currently doing it.

Create a simple text field in your task list as a place holder, "subTask" for example.

Then create a 2010 Workflow in Sharepoint Designer and create a IF statement.

enter image description here

Every top level task does not contain a Parent ID, so any subtask created will have their placeholder field updated as they will contain a Parent ID.

You can then filter your view based on that field.

enter image description here

Hope it helps.

OTHER TIPS

First, your script just show Top-Level Main Tasks (Summary Task) not the Sub-Level Main Tasks.

For Example: If you have subtask (Task2 and Task 4) that is the Main Task for another child subtask (Task 3, Task 5)

- Main Task MQassas 1
 - Task 2
     - Task 3
- Main Task MQassas 2
 - Task 4
     - Task 5

It will only show the Parent Main Task (Main Task MQassas 1, Main Task MQassas 2) as shown below:

enter image description here


Second, To get the same behavior without code in Gantt chart, you should do the following:

  • Setting the Predecessor field for all Subtasks with the Main Task.

enter image description here

[OutPut]

enter image description here

  • Now, Create a new Gantt chart filtered by Predecessor equals empty enter image description here

[OutPut]

enter image description here


An alternative OOTB solution,

You can also create a new column (IsMainTask) that is (Yes or No) to only update the main tasks with yes and filter with this IsMainTask= Yes, in this case, you will update little main tasks instead subtasks!

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top