function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jonathan Wolff 7Jonathan Wolff 7 

Add View All Button to selfmade Task Component

Hi I build a Task component. I would like to add the view all button from the standart into the top right corner. Could you tell me how to modify my code so I can achive this. (I will only show the code sample of the first section "Überfällig" so it will be easier to read)
I already found this side but I dont know how to implement it in my code: https://www.infallibletechie.com/2018/07/adding-view-all-button-in.html

Greetings
JonathanUser-added image
COMPONENT:

<aura:component controller="TaskController" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" >
    
    <aura:attribute name="recordId" type="Id" />    
    <aura:attribute name="tasks" type="Task[]"/>
    <aura:attribute name="tasks2" type="Task[]"/>
    <aura:attribute name="tasks3" type="Task[]"/>
    <aura:attribute name="tasks4" type="Task[]"/>
    
                                              
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>   
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="mycolumns2" type="List"/>
    <aura:attribute name="mycolumns3" type="List"/>
    <aura:attribute name="mycolumns4" type="List"/>
    
    <aura:attribute name="currentDate" type="string"/>
    <aura:attribute name="TomorrowDate" type="string"/>
    <aura:attribute name="AfterTomorrowDate" type="string"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    
                                                 
    <lightning:card iconName="standard:task" title="Tasks">
        <div class="slds-card__body slds-card__body_inner">           
        </div>
        
  <div style= "font-size: 14px; font-weight: bold;">
      Vergangen        
  </div>
        <div>
            <aura:if isTrue="{!not(empty(v.tasks))}">
                <lightning:datatable data="{!v.tasks }" 
                         columns="{!v.mycolumns }" 
                         keyField="Id"
                         hideCheckboxColumn="true"/>
                <aura:set attribute="else">
                    <div Style="text-align : center"> " There are no Tasks currently "</div>
                </aura:set>
            </aura:if>
        </div>
     
    </lightning:card>
</aura:component>

CONTROLLER:
({
    doInit: function(component, event, helper) {
    
         var today = new Date();
        var date = today.getDate();
        var tomorrowdate = today.getDate()+1;
        var aftertomorrowdate = today.getDate()+2;
        var month = today.getMonth()+1;
        var year = today.getFullYear();
        var result = date +'.'+month +'.'+ year;
        var result2 = tomorrowdate +'.'+month + '.' + year;
        var result3 = aftertomorrowdate + '.'+ month +'.' + year;
        component.set('v.currentDate', result);
        component.set('v.TomorrowDate', result2);
        component.set('v.AfterTomorrowDate', result3);
        
      
            component.set('v.mycolumns', [
            {label: 'Subject', fieldName: 'SubjectName', type: 'url',
            typeAttributes: {label: { fieldName: 'Subject' }, target: '_blank'}},
            {label: 'Status', fieldName: 'Status', type: 'picklist'},
        ]);
        var action = component.get("c.loadTasks");
            action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                records.forEach(function(record){
                   
                    record.SubjectName = '/'+record.Id;
                    record.ActivityDate= record.ActivityDate;
                });
                component.set("v.tasks", records);
            }
        });
        $A.enqueueAction(action);
   

APEX:

public with sharing class TaskController {
    
//ÜBERFÄLLIG - Abfrage Tasks, wo das Activity Date abgelaufen und der Status "Not Completed" ist//
@AuraEnabled
public static List<Task> loadTasks(Id recordId){
    string userId = UserInfo.getUserId();
    return[SELECT Subject, ActivityDate, Status FROM Task WHERE WhatId=:recordId And ActivityDate< TODAY AND OwnerId=:userId AND Status !='Completed'];
}


                
ANUTEJANUTEJ (Salesforce Developers) 
Hi Jonathan,

You need to add the view all button snippet from the link you have mentioned to your custom implementation and modify it to fetch the tasks as it is fetching accounts in your implementation.

Additionally, I would suggest you check the below idea link as well that could be related to your scenario:

>> https://trailblazer.salesforce.com/ideaView?id=08730000000KYO2AAO

You can upvote so that if it reaches the necessary threshold number of votes it may be considered in the future.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.