Default array notation separator
Default array notation separator

Hello,
Is there any way to specify the default array notation separator to be used?
Currently, if we do: users[].name
The result will be John,Jane
I would like to add a space after the comma to be: John, Jane
I believe this is what most people would like to use.
I know I can do users[, ].name
but it would be more convenient if it could set it as default.
Also, I am currently working on implementing the array notation support in Yajra Laravel DataTables lib and this will be very helpful if we could specify the default value so we can align it with the separator we use in export.
Answers
users[, ].name
is how to do it, as you say. There isn't an option to set a default for the joining string at the moment I'm afraid.Allan
Thanks for the reply.
As a workaround, any chance this could be done for example by overriding the default renderer?
I tried to override the text renderer, but it looks like this had no effect.
So the issue here is that if you don't supply an characters in the middle of the
[]
, thenDataTable.util.get()
will actually return an array. The result is that what gets written to the document is actually[ 'name1', 'name2' ]
, and.toString()
of an array uses a single comma separator in Javascript. So that comma isn't actually coming from DataTables per se, but from[].toString()
.The return of an array from
DataTable.util.get()
is really useful at times, so changing that isn't an option unfortunately, but I suppose there could be an array renderer so you could do something like:That doesn't seem any easier than doing:
though?
Allan
Thanks for clarifying, Allan.
If you changed the behavior of "users[].name" I'd be in serious trouble. I need an array, and nothing comma or comma & blank separated, in that case. I use this all the time in combination with custom renderers.