• karishma gurjar 3
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I've got a lightning:datatable that looks like this: 
<aura:attribute name="resources" type="Object"/> 
<aura:attribute name="mycolumns" type="List"/> 
<aura:handler name="init" value="{! this }" action="{! c.doInit }"/> 
<lightning:datatable 
data="{! v.resources }" 
columns="{! v.mycolumns }" 
keyField="Id" 
onrowaction="{! c.handleRowAction }" 
hideCheckboxColumn="true" />

with a doInit that looks like this:

doInit: function (component, event, helper) {
        var actions = [
                    { label: 'Select', name: 'selectRecord' },
                ];
        component.set('v.mycolumns', [
                        {type: 'action', typeAttributes: {
                        rowActions: actions,

                        }},
                        {type: "button", typeAttributes: {
                             iconName: 'utility:add',
                             label: '',
                             name: 'selectRecord',
                             title: 'selectRecord',
                             disabled: false,
                             value: 'test',
                             }},
                        {label: 'Resource', fieldName: 'Name', type: 'text'},
                        {label: 'Comment', fieldName: 'Comment__c', type: 'text'},

                    ]);
            },
 
handleRowAction: function (component, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        switch (action.name) {
            case 'selectRecord':
                console.log(row.Id);
                console.log('Showing Details: ' + JSON.stringify(row));
                break;

Here's my issue: I want the button to handle the handleRowAction. I don't want a dropdown menu - how can I make my button handle the action? What's the point of having a button on the lightning:datatable if I can't do anything with it? As of now it seems that only "action" can handle stuff like "select this row" etc.
 
  • April 25, 2018
  • Like
  • 0