I cannot get the render function to be called on my datatable. The data source is an AJAX call and the data comes in fine. But I want to add a link to one of the fields so I am using a render function on that column to build the link.
Here is the pertinent code:
"ajax":{
"url":"ajaxtest.cfc?method=getData",
"dataSrc": "DATA",
"columns": [
{"DATA":"ROLLYEAR"},
{"DATA":"APN",
"render": function (data){
if (data !== null){
return "<a href='pagelink.cfm?id="+data+"'>"+apn+"</a>";
} else {
return "<a href='pagelink.cfm?id="+data+"'>"+apn+"</a>";
}
}},
{"DATA":"ARCNUMBER", "render":"test"},
{"DATA":"APPRAISER"},
{"DATA":"ARCGENERATEDDATE"},
{"DATA":"STATUS"},
{"DATA":"APPROVEDBY"},
{"DATA":"CALAMITYTYPE"},
{"DATA":"DIST"},
{"DATA":"NGH"},
{"DATA":"CL"}
]
}
No matter what I try the APN column is always generated as is with no link. I've even tried putting a console.log
in the render function and get no output to the console. I've tried making the render function something simple like outputting a different text string and still it doesn't work. The data being returned looks like this:
{"COLUMNS":["ROLLYEAR","APN","ARCNUMBER","APPRAISER","ARCGENERATEDDATE","STATUS","APPROVEDBY","CALAMITYTYPE","DIST","NGH","CL","ID","ARCID"],"DATA":[[####,"XXXXX",####,###,"XXXX-XX-XX","XXXX","XXXXX","XXXXX",###.#,###,null,####,####]]}
(I've replaced the data with ### for numbers and XXXX for text fields as the data is a bit sensitive.)
I've tried the more complete render function that looks like this: "render":function (data, type, row,meta)
but that doesn't make any difference either.
Any ideas? I'm at my wits end. I have read many queries on similar issues and I can't get any of those solutions to work here though it looks like it should. I'm sure I'm missing something obvious.
Thanks for any help.