Ag grid column ids dynamically changing adding _1

Column ID's
Each column generated by the grid is given a unique ID. Parts of the Grid API use Column ID's (column identifiers).
If you are using the API and the columns ID's are a little complex (eg what if two columns have the same field, or what if you are using valueGetter instead of field) then it is useful to understand how columns ID's are decided.
If the user provides colId in the column definition, then this is used, otherwise the field is used. If both coldId and fieldthen colId gets preference. If neithercolId or field then numeric is provided. Then finally the ID ensured to be unique by appending '_[n]' where n is the first positive number that allows uniqueness.
In the example below, columns are set up to demonstrate the different ways ID's are generated. Open the example in a new tab and observe the output in the dev console. Note the following:
  • Col 1 and Col 2 both use colId. The grid appends '_1' to Col 2 to make the ID unique.
  • Col 3 and Col 4 both use field. The grid appends '_1' to Col 4 to make the ID unique.
  • Col 5 and Col 6 have neither colIdor field so the grid generates columns.

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation