0

This LWC basically shows different related records to a Policy record based on which tab is selected... See the image here.

enter image description here

As you can see I have the url active but it doesn't lead anywhere, I also tried some stuff on row selection...here is the code...

HTML

<template>
    <lightning-card title = "Schedule Records" icon-name = "custom:custom10">  
        <div class = "slds-m-around_medium">
            <lightning-tabset>
                <lightning-tab label="Aircraft" name="aircraft" onactive={handleClick}>
                    <lightning-datatable 
                        key-field="Name" 
                        data={data} 
                        columns={aircraftColumnList}
                        onrowselection={goToRecord}
                        max-row-selection=1>
                    </lightning-datatable>
                </lightning-tab>
                <lightning-tab label="Airport" name="airport" onactive={handleClick}>
                    <lightning-datatable 
                        key-field="Name" 
                        data={data} 
                        columns={airportColumnList}>
                    </lightning-datatable>
                </lightning-tab>
                <lightning-tab label="Pilot" name="pilot" onactive={handleClick}>
                    <lightning-datatable 
                    key-field="Name" 
                    data={data} 
                    columns={pilotColumnList}>
                </lightning-datatable>
                </lightning-tab>
                <lightning-tab label="OPW" name="opw" onactive={handleClick}>
                <lightning-datatable 
                    key-field="Name" 
                    data={data} 
                    columns={opwColumnList}>
                </lightning-datatable>
                </lightning-tab>
                <lightning-tab label="Training" name="training" onactive={handleClick}>
                <lightning-datatable 
                    key-field="Name" 
                    data={data} 
                    columns={trainingColumnList}>
                </lightning-datatable>
                </lightning-tab>
            </lightning-tabset>
        </div>
    </lightning-card>
</template>

Javascript

import { LightningElement, track, wire, api } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import getSchedules from '@salesforce/apex/ScheduleController.getSchedules';
var selection;
const aircraftColumnList = [
    {label: 'Sched#', fieldName: 'Name', type:'url', typeAttributes: { label:{fieldName: 'Name'}, target: '_blank'}},
    {label: 'N#', fieldName: 'AircraftNNumber__c'},
    {label: 'Year', fieldName: 'AircraftYear__c'},
    {label: 'Make', fieldName: 'AircraftMake__c'},
    {label: 'Model', fieldName: 'AircraftModel__c'},
    {label: 'Use', fieldName: 'AircraftUse__c'},
    {label: 'Crew Seating', fieldName: 'AircraftCrewSeating__c'},
    {label: 'Passenger Seating', fieldName: 'AircraftPassengerSeating__c'},
    {label: 'Landing Gear', fieldName: 'AircraftLandingGear__c'},
    {label: 'Storage', fieldName: 'AircraftStorage__c'}

];
const airportColumnList = [
    {label: 'Sched#', fieldName: 'Name'},
    {label: 'Airport Id', fieldName: 'Airport_2__r.Name'},
    {label: 'Secondary Id', fieldName: 'AirportSecondaryId__c'},
    {label: 'Airport Name', fieldName: 'AirportName__c'},
    {label: 'City', fieldName: 'AirportCity__c'},
    {label: 'State', fieldName: 'AirportState__c'},
    {label: 'Length of Runway', fieldName: 'AirportLengthOfRunway__c'},
    {label: 'Surface', fieldName: 'AirportSurface__c'},
    {label: 'Airport Use', fieldName: 'AirportUse__c'}

];
const pilotColumnList = [
    {label: 'Sched#', fieldName: 'Name'},
    {label: 'Pilot Name', fieldName: 'Pilot__r.Name'},
    //{label: 'Pilot Name', fieldName: 'Pilot_Name__c'},
    {label: 'Total Hours', fieldName: 'PIlotTotalHours__c'},
    {label: 'Hrs in Last 12 months', fieldName: 'PilotHrsInLast12Months__c'},
    {label: 'Age', fieldName: 'PilotAge__c'},
    {label: 'Pilot Form Date', fieldName: 'PilotFormDate__c'},

];
const opwColumnList = [
    {label: 'Sched#', fieldName: 'Name'},
    {label: 'OPW Requirements', fieldName: 'OPW_Requirements__c'}

];
const trainingColumnList = [
    {label: 'Sched#', fieldName: 'Name'},
    {label: 'Training Reqirements', fieldName: 'Training_Requirements__c'}

];
export default class ScheduleDataTable extends NavigationMixin(LightningElement) {
    @api recordId;
    @track data;
    @track error;
    @track aircraftColumnList = aircraftColumnList;
    @track airportColumnList = airportColumnList;
    @track pilotColumnList = pilotColumnList;
    @track opwColumnList = opwColumnList; 
    @track trainingColumnList = trainingColumnList;
    @track noRecordsFound = true;


handleClick(event) {
    this.getType = event.target.name;
    getSchedules({strScheduleType: this.getType, polId: this.recordId})
        .then(result => {
            this.data = result;
        })
        .catch(error =>  {
            this.error = error;
        });
    };
goToRecord(event) {
    this.record = event.detail.row;
    this[NavigationMixin.Navigate]({
        type: 'standard__recordPage',
        attributes: {
            //recordId: event.detail.id,
            recordId: this.record.id,
            //objectApiName: this.objectApiName,
            actionName: 'view'
        },
    });
};  
5
  • you are talking about clicking on that radio button beside each each row or on that "sched#" field?
    – User6670
    Mar 30 '20 at 15:52
  • that would be clicking the radio button, sorry for the confusion!
    – Colby Flye
    Mar 30 '20 at 15:56
  • i think we use 'event.detail.selectedRows', did you get anything in 'event.detail.row'
    – User6670
    Mar 30 '20 at 15:59
  • @User6670 I did not get anything. Selected rows had no result either.
    – Colby Flye
    Mar 30 '20 at 16:35
  • you can do this salesforce.stackexchange.com/questions/257065/…
    – User6670
    Mar 30 '20 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.