0

I'm using a datatable, i think the syntax is ok but the data doesn't show up. here is the HTML:

<aura:attribute name="listBaPriveCmp" type="List"/>
<aura:attribute name="mycolumnsBAPrive" type="List"/>
<aura:attribute name="draftValues" type="Object" default="[]"/>
<div>
        <lightning:datatable
                            columns="{!v.mycolumnsBAPrive}"
                            data="{!v.listBaPriveCmp}"
                            keyField="id"
                            hideCheckboxColumn="true"
                            draftValues="{!v.draftValues }"
                            onsave="{!c.handleSaveEdition }"/>
    </div>

the Js controller:

doInit : function(component, event, helper) {
    debugger;
    
    
    
    component.set('v.mycolumnsBAPrive', [
        {label: 'Nom', fieldname: 'nom', type : 'text', editable: false},
        {label: 'Mandaté pour payer', fieldname: 'mandate', type: 'text', editable : false},
        {label: 'Email Principal 1', fieldname: 'principal1', type : 'text', editable : true, typeAttributes: { required: true }},
        {label: 'Email Principal 2', fieldname: 'principal2', type : 'text', editable : true},
        {label: 'Email Secondaire 1', fieldname: 'secondaire1', type : 'text', editable : true},
        {label: 'Email Secondaire 2', fieldname: 'secondaire2', type : 'text', editable : true}
    ]);
}

And the helper: there is to way of pushing value in the listBaPrive list. 1/

if(champsBA.Dmatrialisation__c === 'PRIVE'){
                            let inputTableauPrive = {id : listBA[i].idBillingAccount, nom : listBA[i].nomBillingAccount, mandate : listBA[i].compteMandate, principal1 : listBA[i].principal1, principal2 : listBA[i].principal2, secondaire1 : listBA[i].secondary1, secondaire2 : listBA[i].secondary2};
                            console.log('inputTableauPrive = ' + JSON.stringify(inputTableauPrive)); 
                            listBaPrive.push(inputTableauPrive);
                            
                        }

2/

if(champsBA.Dmatrialisation__c === 'PRIVE'){

            console.log('BA PRIVE NON EXISTANT');
                let idNewBa;
                if(listLCselectionnes[j].isRecurrent){
                    idNewBa = 'R';
                }else{
                    idNewBa = 'P'
                }
                let inputTableauPrive = {id : idNewBa, nom : 'NOUVEAU', mandate : champsBA.CRMIDduMandatePourPayer3__c, principal1 : champsBA.Principal1__c, principal2 : champsBA.Principal2__c, secondaire1 : champsBA.Secondary1__c, secondaire2 : champsBA.Secondary2__c};

                console.log('inputTableauPrive = ' + JSON.stringify(inputTableauPrive));
                listBaPrive.push(inputTableauPrive);
                
            }

Even if i you only one way it doensn't work. then at the end of the method:

if($A.util.isEmpty(listTotalLC)){
        console.log('listTotalLC is EMPTY');        
        console.log('listBaPrive = ' + JSON.stringify(listBaPrive));

        //Suppression des doublons
        let listBAPriveUnique = Array.from(new Set(listBaPrive.map(ba => ba.id))).map(id => {

            console.log('id = ' + JSON.stringify(id));

            return listBaPrive.find(ba => ba.id === id)
            });

        console.log('listBAPriveUnique = ' + JSON.stringify(listBAPriveUnique));
        component.set('v.listBaPriveCmp', listBAPriveUnique);
    }

when i execute, i see the column header and the correct number of line from the list but not the values: enter image description here

Here are the values:

listBAPriveUnique = [

{"id":"P","nom":"NOUVEAU","mandate":"0010Q00000xzDrRQAU","principal1":null,"principal2":null,"secondaire1":null,"secondaire2":null},{"id":"R","nom":"NOUVEAU","mandate":"0010Q00000xzDrRQAU","principal1":null,"principal2":null,"secondaire1":null,"secondaire2":null} ]

Could you guys help me? thanks!

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.