Created
May 3, 2019 07:41
-
-
Save choudharymanish8585/94e0d7adb751ce36a6c9a35397da592b 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, track } from 'lwc'; | |
//Let's configure the columns of the data table | |
const columns = [ | |
//Key here is cellAttributes object for Particular column | |
{label: 'Name', fieldName: 'name', type: 'text'}, | |
//Diet type column can accept a css class. The css class name should be passed in field name "dietClass" from server | |
{label: 'Diet Type', fieldName: 'diet', type: 'text', cellAttributes: { class: { fieldName: 'dietCSSClass' }}}, | |
{label: 'Blood Group', fieldName: 'bloodGroup', type: 'text'}, | |
//likewise fvtColor column can also have a css class in fvtColorCSSClass field | |
{label: 'Favourite Color', fieldName: 'fvtColor', type: 'text', cellAttributes: { class: { fieldName: 'fvtColorCSSClass' }}}, | |
//and working column can have a css class in workingCSSClass field | |
{label: 'Working', fieldName: 'working', type: 'boolean', cellAttributes: { class: { fieldName: 'workingCSSClass' }}} | |
]; | |
export default class ColorColumnDataTable extends LightningElement { | |
@track data = []; | |
@track columns = columns; | |
connectedCallback(){ | |
const data = []; | |
data.push({name : 'Manish', diet : 'Vegeterian', dietCSSClass : 'slds-text-color_success', bloodGroup : 'AB+', | |
fvtColor : 'Blue', fvtColorCSSClass : 'slds-icon-custom-custom9', working : true, workingCSSClass : 'slds-icon-custom-14'}); | |
data.push({name : 'Peter', diet : 'Non-Vegeterian', dietCSSClass : 'slds-text-color_error', bloodGroup : 'B+', | |
fvtColor : 'Grey', fvtColorCSSClass : 'slds-color__background_gray-7', working : true, workingCSSClass : 'slds-icon-custom-14'}); | |
data.push({name : 'Alex', diet : 'Non-Vegeterian', dietCSSClass : 'slds-text-color_error', bloodGroup : 'A-', | |
fvtColor : 'Blue', fvtColorCSSClass : 'slds-icon-custom-custom9', working : false, workingCSSClass : 'working-false'}); | |
data.push({name : 'Shane', diet : 'Non-Vegeterian', dietCSSClass : 'slds-text-color_error', bloodGroup : 'O+', | |
fvtColor : 'Green', fvtColorCSSClass : 'slds-icon-custom-custom79', working : true, workingCSSClass : 'slds-icon-custom-14'}); | |
data.push({name : 'Malisa', diet : 'Vegeterian', dietCSSClass : 'slds-text-color_success', bloodGroup : 'AB-', | |
fvtColor : 'Orange', fvtColorCSSClass : 'slds-icon-custom-custom102', working : false, workingCSSClass : 'working-false'}); | |
data.push({name : 'Angelina', diet : 'Vegeterian', dietCSSClass : 'slds-text-color_success', bloodGroup : 'AB+', | |
fvtColor : 'Pink', fvtColorCSSClass : 'slds-icon-custom-custom24', working : false, workingCSSClass : 'working-false'}); | |
data.push({name : 'Liana', diet : 'Non-Vegeterian', dietCSSClass : 'slds-text-color_error', bloodGroup : 'B+', | |
fvtColor : 'Cyan', fvtColorCSSClass : 'slds-icon-custom-custom20', working : false, workingCSSClass : 'working-false'}); | |
data.push({name : 'Holly', diet : 'Vegeterian', dietCSSClass : 'slds-text-color_success', bloodGroup : 'B-', | |
fvtColor : 'Grey', fvtColorCSSClass : 'slds-color__background_gray-7', working : true, workingCSSClass : 'slds-icon-custom-14'}); | |
data.push({name : 'Rick', diet : 'Vegeterian', dietCSSClass : 'slds-text-color_success', bloodGroup : 'A+', | |
fvtColor : 'Grey', fvtColorCSSClass : 'slds-color__background_gray-7', working : true, workingCSSClass : 'slds-icon-custom-14'}); | |
this.data = data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment