AGrigorii
AGrigorii

Reputation: 152

Ag-grid column definition and `__metadata__` property

I need to introduce object with my own properties in columnDefs object. After, I did it, I see warning in dev console

So, here has been written, that I could mean __metadata__ property. Does this property suit to mine purpose?

I've not found any information in types and docs about this property

Upvotes: -1

Views: 1251

Answers (1)

Josef Bláha
Josef Bláha

Reputation: 1113

ColDef has no custom state property that you could use. Certainly do not touch __metadata__. The name sounds like some internal implementation detail.

You can store your metadata in a separate object, for example using colId as a key:

columnDefs: ColDef[] = [
  {
    colId: 'id',
    field: 'id'
  },
  {
    colId: 'name',
    field: 'name'
  }
];

columnMetadata: {
  id: 'something custom',
  name: 'custom data'
}

private getColumnMetadata(column: Column) {
  return this.columnMetadata[column.getColId()];
}

Upvotes: 0

Related Questions