Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82314

Dynamic (AJAX sourced) advanced functions

$
0
0

I have most of my DT options brought back via JSON and I'm looking to do even more with that. As a quick example I have JSON that passes configuration options for columns, datatables itself as well as the data. I'm doing all of this to keep my front end logic fairly minimal if possible.

To aid this, I want to do more complex tasks like returning a function definition within JSON and running that. For example, I'd like to use a render function (https://datatables.net/manual/data/renderers) on the fly. I've used the ellipsis plugin before so that would be one example that I'd like to be able to pass it back and be recognized as JSON. Right now it throws the unrecognized parameter error. I tried passing a function back as JSON but that isn't picked up either.

I loosely know that JS allows a function to be created on the fly using something like new Function(JSON) so I'm wondering if that could be used to aid in what I'm trying to do. I've also tried defining the function in JS and trying to have the render option call it, such as column.render = testFormat(data,type,row) but no luck with that either.

Is there a way either with a combination of DT options or using the API that I can return a dynamic function and have DT recognize it? Has anyone ever done this?


Viewing all articles
Browse latest Browse all 82314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>