[SalesForce] Winter 18 problems

Since I face many questions with this new base lightning component: lightning:datatable, I think it is better to have all the questions here in one place:

  1. I want to have a clickable row for "Click to edit" or "Click to Delete" functionality for each row, or a column for editing each row – how can I achieve that? The available checkboxes are not a good option because they can be multiple selected, and also I need many functionalities for each row (edit, delete, etc.).

enter image description here

  1. I tried to play with the data of the column and set attributes of text type column with the lightning:formattedText and of url type column with the lightning:formattedUrl – according to the doc you can set their attributes with setting in the column object typeAttributes: { attributeName: 'value' } – I could not set any attribute in this way (currency code does work – as in their example, but not all other attributes. Maybe a good example would help me.

  2. I created another Question for a problem with a displaying data from a parent field.

  3. I am trying to set the column width with my keyboard and with my mouse (according to the doc), but it is not working – why?

  4. I am trying to set a fixed initial size for some columns, and it is not working – here is my column array:

    [{label: 'Id', fieldName: 'Id', type: 'id', sortable: true, initialWidth: "50x"},
    
    {label: 'First Name', fieldName: 'FirstName', type: 'text', sortable: true},
    
    {label: 'Last Name', fieldName: 'LastName', type: 'text', sortable: true}]
    

Best Answer

1) lightning:datatable does not allow to react to a click or double click over a particular row. This version of the component is read-only.

Row level action I think is what you need. Its coming in next release. Basically you can have a column type="actions" and the cells of that column have a buttonMenu with the actions you want to apply to rows.

is there a work around for that today? Not ideal but you can use checkboxes and actions button(edit, remove, view) outside of the table, those button could be disabled if more than one row is selected or no row is selected.