You need to sign in to do that
Don't have an account?
Amrita 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') }"> ↓ </aura:if>
<aura:if isTrue="{! and(v.arrowDirection != 'arrowdown', v.selectedTabsoft == 'Manager') }"> ↑ </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");
}
},
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') }"> ↓ </aura:if>
<aura:if isTrue="{! and(v.arrowDirection != 'arrowdown', v.selectedTabsoft == 'Manager') }"> ↑ </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");
}
},
Check out this link,it might help you you acheive your requirement.
https://developer.salesforce.com/forums/?id=9060G0000005bJaQAI
Cheers!!!
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>
You can style the lightning icon with you background color and on hover add another class with different color.
Cheers!!!