Passing render function from server-side

Passing render function from server-side

alsaleemalsaleem Posts: 4Questions: 1Answers: 0

I am trying to control the render function based on the request parameter :
The datatables is created from options obtained from an ajax call as below.

var data = JSON.parse(rxdata); // <== received from server via ajax call
var opts = {
    processing: true,
    serverSide: true,
    columnDefs: [{targets:4, render: fmtCheck}],
    ajax: {
        url: 'frmuserdata.php',
        type: 'POST',
        data: { func: "user_data" }
    }
};
opts = Object.assign(opts, data);  // <== other options are received from server ajax call (data) 
user_table = $('#users').DataTable( opts );

That goes ok and data rendering function is called perfectly. I am using ssp.class.php to query table data

Now, I need php code to set the render function when a table is created by passing the render.function name.

In php :
$opts['columnDefs'] = array(array('targets: 4, 'render': 'fmtCheck'));
also tried :
$opts['columnDefs'] = array(array('targets: 4, 'render': 'fmtCheck()'));

But none worked. I got warning (https://datatables.net/manual/tech-notes/4 ).
Do I need to set other option to make datatables allow render function being set from json?

Thanks,

Answers

Sign In or Register to comment.