Question:
Let's get to the problem. In datatable.js, to display the columns I define it as follows:
"aoColumns": [
{ "mDataProp": "IdProcesso", "sTitle": "Numero" }
]
If you need to perform any function:
{
"mDataProp": "DataAbertura", "sTitle": "Data Abertura",
"fnRender": function (oObj) {
return //minha function vem aqui!
}
},
Now comes the question, is it possible for me to add this function to the Json object dynamically? When I say dynamic I mean the fact that this object will be created by another function and at the end it returns a string generated by JSON.stringify and the function is unusable. I hope I managed to explain my doubt
Answer:
There is an alternative, using the eval
function.
The eval
function executes the string
passed to it, as you can see in the example below:
https://jsfiddle.net/yrzruztw/
eval('alert("teste")');
This will make the alert appear on the screen. So my suggestion is that you save your function in string
format, and run it like that.