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
Amrita Panda 2Amrita Panda 2 

How to add on mouse over functionality in a column in lightning table?

requirements - 
on mouse over the "manager" column should show an manager column along with an arrow.

component-

<th class="slds-is-sortable slds-text-title--caps" scope="col" onmouseover="{!c.arrowshow}" onclick="{!c.sortManager}"><div class="slds-truncate slds-cell-fixed" style="width: 980px;padding-left: 10px;padding-top: 10px;" title="Manager">Manager
                                    <aura:if isTrue="{! and(v.arrowDirection == 'arrowdown', v.selectedTabsoft == 'Manager') }">&nbsp; &#8595;  </aura:if>  
                                    <aura:if isTrue="{! and(v.arrowDirection != 'arrowdown', v.selectedTabsoft == 'Manager') }"> &nbsp; &#8593;  </aura:if>   
                                    </div></th>

controller.js-

  sortManager: function(component, event, helper) {
          try {
                   component.set("v.selectedTabsoft", 'Manager');
                 helper.sortManagerHelper(component, event, 'Manager');
          }
          catch(Err){
            helper.showToast(component, 'Error',"Error Occured While Loading Component", "Error");
        }
    },
     arrowshow: function(component, event, helper) {
           var arw = component.find('Manager');
          $A.util.addClass(arw,'arrowdown');

    },

helper-

sortManagerHelper: function(component, event, sortField,isAsc) { 
        try {
            var currentDir = component.get("v.arrowDirection");
            if (currentDir == 'arrowdown') {
                component.set("v.arrowDirection", 'arrowup');
                component.set("v.isAsc", true);
                component.set("v.isSort", true);
            } else {
                component.set("v.arrowDirection", 'arrowdown');
                component.set("v.isAsc", false);
                component.set("v.isSort", true);
            }
            this.doinitHelper(component, event);
        }
        catch(Err){
            helper.showToast(component, 'Error',"Error Occured While Loading Component", "Error");
        }
    },
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Amrita

Check out this link,it might help you you acheive your requirement.

https://developer.salesforce.com/forums/?id=9060G0000005bJaQAI

Cheers!!!
Amrita Panda 2Amrita Panda 2
Now i am getting the sort thing correct but the only concern is onhover on the "manager" by default is shows me the "upward arrow" but instead i  want there shouldn't be any arrow there....when page loads it should be only"manager" and no icon beside it.

component-

 <th  aria-label="Manager"  aria-sort="Other" class=" slds-is-resizable slds-is-sortable slds-text-title--caps" scope="col" onclick="{!c.sortManager}">
                                    <a  class=" slds-text-link_reset" href="javascript:void(0);">
                                    <div class="slds-th__action slds-truncate slds-cell-fixed"  style="width: 150px;padding-left: 10px;padding-top: 10px;" title="Manager">Manager
                                       <aura:if isTrue="{! and(v.arrowDirection == 'arrowdown', v.selectedTabsoft == 'Manager') }"> 
                                           
                                    <lightning:icon  size="x-small" iconName="utility:arrowdown" />
                                          
                                    </aura:if>  
                                    <aura:if isTrue="{! and(v.arrowDirection != 'arrowdown', v.selectedTabsoft == 'Manager') }"> 
                                       
                                    <lightning:icon size="x-small" iconName="utility:arrowup" />
                                       
                                    </aura:if>  
                                        </div>
                               </a>
                                    </th>
Amrita Panda 2Amrita Panda 2
kindly help...its urgent!!
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Amrita

You can style the lightning icon with you background color and on hover add another class with different color.

Cheers!!!