DataTables column name containing brakets
DataTables column name containing brakets
depaula
Posts: 2Questions: 1Answers: 0
First of all I'm using DataTables version 1.10.12
Follow an example:
Columns:
columns: [
{title: "Id", data: "id"},
{title: "Name", data: "Person[name]"},
{title: "Gender", data: "Person[gender]"},
]
Data
[{
"id":"1",
"Person[name]":"Foo Bar",
"Person[gender]":"M"
}]
The result of this grid will render only id field, how can I use brackets as key values?
This question is asked too in Stack Overflow:
http://stackoverflow.com/questions/38624131/datatables-column-name-containing-brakets?noredirect=1#comment64634463_38624131
This discussion has been closed.
Answers
That's a good one - I'm afraid you've run into a limitation in DataTables' data read options there. With a
.
you can escape it incolumns.data
to have it work, but that hasn't been implemented for[]
.I've just put a little test case together here: http://live.datatables.net/jalemizu/1/edit .
Until I get a chance to implement that, I'm afraid the only option is to modify the JSON data property names.
Allan
I will share a solution given by User Gyrocode.com.