Sending custom column attributes to the server on POST
Sending custom column attributes to the server on POST
kmd1970
Posts: 36Questions: 8Answers: 1
I am using Datatables version 1.10.4
I would like to send a custom column attribute to the server on POST for every column. (I can't use the "Name" attribute.)
Example :
For each column I would like to send an "Alias" value to the server.
$('#example').dataTable( {
"columns": [
{ "data": "engine", "alias" : "engine_type" },
{ "data": "browser", "alias" : "browser_type" },
{ "data": "platform", "alias" : "platform_version" },
{ "data": "version", "alias" : "version_number" },
{ "data": "grade", "alias" : "grade_level" }
]
} );
I assume the array sent would look like this if successful :
columns[0][data] engine
columns[0][name]
columns[0][alias] engine_type
columns[0][orderable] false
columns[0][search][regex] false
columns[0][search][value]
columns[0][searchable] false
columns[1][data] browser
columns[1][name]
columns[1][alias] browser_type
columns[1][orderable] false
columns[1][search][regex] false
columns[1][search][value]
columns[1][searchable] false
... etc, etc, etc
Any help would be appreciated
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Use either
ajax.data
orpreXhr
to add additional information to the data sent to the server.Allan
Hi Allan, Yes, I am using
ajax.data
to send additional information to server but I want to set the custom attributes at the column level. Custom per column attributes like data, name, search, etc.I suppose I could use
ajax.data
and the column index for every column but thatis going to look a bit sloppy.
Why wouldn't you just use a
for
loop? Certainly, if you want to add a property to each element in the array you either need to do it in a loop or statically, I don't see what other option there is?Allan
Not using
for
loop since the custom attribute values are different for each column.Actually, your first suggestion should work, although I am no longer able to mark it as the answer. Thanks again.