• fatih berber 7
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello

I have a lightning:datatable that is fully working, however my management is asking for a slight change, but I cannot find how to do this in the documentation.

For each row of the table, there is a Details button available but first the users must click on the  Down arrow next to it.
This Details button call a JS method in the controller, and the JS method is able to see which row was clicked.

See screenshot :

User-added image
My management wants a simple link instead of the Details button.
Of course this link should be able to call the same JS method, and the JS method should be able to see which row was clicked.

Is that possible?

Here is my code currently :
 
<lightning:datatable data="{!v.searchResults}" columns="{!v.resultColumns}"  keyField="siret" hideCheckboxColumn="true" onrowaction="{!c.seeDetails}" />
init: function (component, event, helper) {
        //This method is called on initialization
        //It formats the lightning:dataTable that will display the results with the appropriate columns and data types
        
         var actions = [
            { label: 'Détails', name: 'show_details' },
        ];
        
        component.set('v.resultColumns', [
             		{label: 'Provenance', 						fieldName: 'provenanceAsIcon', 		    				cellAttributes: { iconName: { fieldName: 'provenanceAsIconName' }, iconLabel: { fieldName: 'provenanceAsIconLabel' } }},
             		{label: 'Siret', 							fieldName: 'siret', 					type: 'text'},
            		{label: 'Nom du Compte / Raison Sociale', 	fieldName: 'nomCompteRaisonSociale', 	type: 'text'},
                    {label: 'Adresse', 							fieldName: 'adresse', 					type: 'text'},
            		{label: 'CP', 								fieldName: 'cp', 						type: 'text'},
            		{label: 'Ville', 							fieldName: 'ville', 					type: 'text'},
            		{ type: 'action', typeAttributes: { rowActions: actions } }
                ]);
    }
seeDetails: function (cmp, event, helper) {
        //This method is called when the user clicks on "Voir les détails" at the row-level of the results
        //First it checks if the row that was clicked is a SF or CS record
        
        //Retrieving the provenance (SF or CS) and recordId of the row that was clicked
        var row = event.getParam('row');
        var rows = cmp.get('v.searchResults');
        var rowIndex = rows.indexOf(row);
        var provenance = rows[rowIndex]['provenance'];
        var recordId = rows[rowIndex]['recordId'];

	//More processing...