AKHIL NAMBIAR
AKHIL NAMBIAR

Reputation: 23

Appending dynamic field to object

I'm getting field name using:

var getColumnName = params.colDef.field;

I want to make params.data to have field which is stored in getColumnName and set the value null to make it accessible like:

params.data.name

Upvotes: 0

Views: 37

Answers (1)

Alejandro De Cicco
Alejandro De Cicco

Reputation: 1236

Use array notation instead of object notation:

if (!params.data) params.data = {};
params.data[getColumnName] = null;

Upvotes: 2

Related Questions