Created
May 22, 2022 16:57
-
-
Save Frelseren/ae56a87f77654bea7542bf826ecae1be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement } from 'lwc'; | |
import { NavigationMixin } from 'lightning/navigation'; | |
import { subscribe } from 'lightning/empApi'; | |
export default class CustomDataTable extends NavigationMixin(LightningElement) { | |
data = [ | |
// data table data | |
]; | |
columns = [ | |
// other data table column definitions, | |
{ | |
initialWidth: 120, | |
type: 'button', | |
typeAttributes: { | |
label: 'Create task', | |
name: 'create_task', | |
title: 'Create task', | |
variant: 'brand' | |
}, | |
}, | |
] | |
subscription = {}; | |
CHANNEL_NAME = '/event/Refresh_Record__e'; | |
_handleRefreshRecord(event) { | |
// business logic to refresh UI | |
} | |
handleRefreshRecord = _handleRefreshRecord.bind(this) | |
connectedCallback() { | |
subscribe(this.CHANNEL_NAME, -1, this.handleRefreshRecord).then(response => { | |
this.subscription = response; | |
}); | |
} | |
handleRowAction(event) { | |
const { action, row } = event.detail; | |
const defaultFieldValues = encodeDefaultFieldValues({ | |
WhatId: row.WhatId, | |
}); | |
this[NavigationMixin.Navigate]({ | |
type: 'standard__objectPage', | |
attributes: { | |
objectApiName: 'Task', | |
actionName: 'new', | |
}, | |
state: { | |
defaultFieldValues, | |
navigationLocation: 'RELATED_LIST' | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment