const actions = [
{ label: 'Share with Client', name: 'share' },
];
const columns = [
{
label: 'Title',
fieldName: 'docURL',
type: 'url',
typeAttributes: {label: { fieldName: 'Title' },
target: '_blank'},
initialWidth: 300,
sortable: "true"
},
{ label: 'Document Type', fieldName: 'DocType', sortable: "true"},
{ label: 'Date uploaded', fieldName: 'createdDate', type: 'date', sortable: "true" },
{
label: 'Shared with client',
fieldName: '',
cellAttributes: { iconName: { fieldName: 'TransferStatus' },
class: 'slds-align_absolute-center' },
sortable: "true"
},
{ label: 'Date shared with client', fieldName: 'TransferedDate', type: 'date', sortable: "true" },
{ label: 'Uploaded by', fieldName: 'createdBy', sortable: "true" },
{
type: 'action',
typeAttributes: { rowActions: actions, disabled: { fieldName: 'hideDocTransferButton' } },
},
];
export default class DatatableWithRowActions extends LightningElement {
@track data = [];
@api recordId;
columns = columns;
record = {};
@track sortBy;
@track sortDirection;
selectedRows=[];
selectedData=[];
cardTitle = 'Files'
_wiredResult;
loaded = false;
@wire(getDocumentList, {recordId: '$recordId'} )
wiredCallback(result) {
this._wiredResult = result;
if (result.data) {
this.data = result.data;
console.log('******this.data*****', JSON.parse(JSON.stringify(this.data)));
this.loaded = true;
}
}
handleRowSelection(event) {
let selectedRows = event.target.selectedRows;
this.selectedRows = selectedRows;
}
handleRowAction(event) {
const actionName = event.detail.action.name;
const row = event.detail.row;
switch (actionName) {
case 'share':
this.handleTransAction(row);
break;
default:
}
}
}
const actions = [
{ label: 'Share with Client', name: 'share' },
];
const columns = [
{
label: 'Title',
fieldName: 'docURL',
type: 'url',
typeAttributes: {label: { fieldName: 'Title' },
target: '_blank'},
initialWidth: 300,
sortable: "true"
},
{ label: 'Document Type', fieldName: 'DocType', sortable: "true"},
{ label: 'Date uploaded', fieldName: 'createdDate', type: 'date', sortable: "true" },
{
label: 'Shared with client',
fieldName: '',
cellAttributes: { iconName: { fieldName: 'TransferStatus' },
class: 'slds-align_absolute-center' },
sortable: "true"
},
{ label: 'Date shared with client', fieldName: 'TransferedDate', type: 'date', sortable: "true" },
{ label: 'Uploaded by', fieldName: 'createdBy', sortable: "true" },
{
type: 'action',
typeAttributes: { rowActions: actions, disabled: { fieldName: 'hideDocTransferButton' } },
},
];
export default class DatatableWithRowActions extends LightningElement {
@track data = [];
@api recordId;
columns = columns;
record = {};
@track sortBy;
@track sortDirection;
selectedRows=[];
selectedData=[];
cardTitle = 'Files'
_wiredResult;
loaded = false;
@wire(getDocumentList, {recordId: '$recordId'} )
wiredCallback(result) {
this._wiredResult = result;
if (result.data) {
this.data = result.data;
console.log('******this.data*****', JSON.parse(JSON.stringify(this.data)));
this.loaded = true;
}
}
handleRowSelection(event) {
let selectedRows = event.target.selectedRows;
this.selectedRows = selectedRows;
}
handleRowAction(event) {
const actionName = event.detail.action.name;
const row = event.detail.row;
switch (actionName) {
case 'share':
this.handleTransAction(row);
break;
default:
}
}
}