get column data from a second ajax call
get column data from a second ajax call
I have column data populated from a restful endpoint. I wanted to add a custom column that gets populated from another ajax query.
My data comes from a '/data/' endpoint, using the sAjaxSource attribute in the DataTables object.
I'm using the "aoColumnDefs" attribute with "mData" attributes on the rows to define my rows.
Can I pass a value, say from the "name" column of my original data to a different endpoint, say "/data/search/[name]", and use the results from that endpoint to populate a field, maybe using the "drawCallback" method?
Or does all of this need to be done server-side, beforehand?
Apologies if this is somewhere in the docs and I just missed it.
Thanks
heres some code if it helps
var table = $('#table_id').DataTable({
"bFilter": false,
"responsive": true,
"sAjaxSource": "/data/",
"bProcessing": true,
"drawCallback": function(settings){
applyColoration();
},
"aoColumnDefs" : [
{ "mData": "name", "aTargets": [0],
"mRender": function(name, type, data) {
return '
' + name + '
';
}
},
{ "mData": "updated_at", "aTargets": [1], "bVisible": false },
{ "mData": "verify", "aTargets": [2], "bVisible": false },
{ "mData": "cas", "aTargets": [3] },
{ "mData": "type", "aTargets": [4], "bVisible": false},
{ "mData": "drugbank_id", "aTargets": [5] },
{ "mData": "unii", "aTargets": [6]},
{ "mData": "inn", "aTargets": [7] }
]});