How to set column names with an array of strings?
How to set column names with an array of strings?
luizbillsantos
Posts: 2Questions: 0Answers: 0
For example,
I have an array like this:
var columnsKeys = ["ID", "Name", "Age", "City"];
how to set the property "columns": [
{ "data": columnkeys[0] },
{ "data": columnkeys[1] },
{ "data": columnkeys[2] },
{ "data": columnkeys[3] },
{ "data": columnkeys[4] }
]
dynamically like a simple "columns": columnsKeys, ?
thanks
This discussion has been closed.
Replies
looks like "columns" is an array of objects.
Why not try this:
Thanks so much rf1234, it's so simple, kkkk
but this wont' really work if you have a more complex setup with multiple properties of a column, e.g. like this:
In case you only wanted to change the "data" property of each object within the array you could do something like this:
The alerted value was ID ...