mardi 26 mai 2020

I want to set checkbox to true based on a condition in ag-grid

I have a button which basically imports some data. This imported data needs to be compared with the data inside already loaded ag-grid and if there is a match, set the cehckbox of that particlar row node to true.

This is the button which checks for the condition:

    enableCheck() {
    alert('works');
    if (this.DataService.isNotBlank(this.rowDataImport)) {
        for (let i = 0; i < this.rowDataImport.length; i++) {
            if (this.DataService.isNotBlank(this.rowData)) { 
                for (let j = 0; j < this.rowData.length; j++) { 
                    if (this.DataService.isNotBlank(this.rowData[j].calDate)) {
                        for (const calDates of this.rowData[j].calDate) {
                            if (
                            this.rowDataImport[i].isin === calDates.isin ||
                            this.rowDataImport[i].portfolioName === calDates.portfolioName ||
                            this.rowDataImport[i].valuationDate === calDates.valuationDate
                                ) 
                                {
                                     // alert('true')
                                    this.checkValue = true;
                                } else {
                                    this.checkValue = false;                                        
                                }
                        }
                    }
                }
            }
        }
      }

}

The this.checkValue is a flag which will be true if match is found.

  public gridColumnDefs = [
        {
            headerName: 'Portfolio Name',
            field: 'portfolioName',
            cellRenderer: 'agGroupCellRenderer',
            headerCheckboxSelection: true,
            headerCheckboxSelectionFilteredOnly: true,
            checkboxSelection: true,
            pinned: 'left',
            filter: true,
            cellRendererParams:(params) => {
                console.log(params);
                if (this.checkValue) {
                 params.node.selected = true;
                }
            }
        },
]

here I used cellRendererParams. But this will only for on load I guess. What to do if I want to update the ag-grid row from a value outside i.e. from import check as given above?




Aucun commentaire:

Enregistrer un commentaire