• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

340
Views
"setColumnDefs" is not working on version 26.1.0 (Angular)

I have an angular project that uses Ag-Grid and here is my problem.

I thing that I have tried all that is in my hand but I'm not able to make it work... My code needs to add and remove some Columns dynamically, and in the documentation I saw that setColumnDefs from the GridApi was a good idea to try it.

I don't know If I'm doing something wrong, but I tried to follow the docs as much as I can.

This is the method that updates the columns definitions (it doesn't work)

updateColumnsMode(): void {
  if(!this.showAdvancedColumns) {
    this.gridOptions
        .api!
        .setColumnDefs(this.buildColumns(this.advancedColumnsName)));
  } else {
    this.gridOptions
        .api!
        .setColumnDefs(this.buildColumns(this.normalColumnsName)));
  }
}

My grid Options

gridOptions: GridOptions = {
  rowData: this.rowData,
  columnDefs: this.buildColumns(this.normalColumnsName),
  onGridReady: (event:any) => console.log("Grid working!"),
}

And the api initialization

onGridReady(params: any) {
  this.gridApi = params.api;
  this.gridColumnApi = params.columnApi;
}

And if it could be relevant, the method where I build the columns

buildColumns(columnsToBuild: String[]): ColDef[] {
  return columnsToBuild.map((column):any => {
    return { "field": column, sortable: true, filter: true }
  });
}

The columnsToBuild is jut an array of String.

I really need help with this guys.

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error