call a function on mrender
call a function on mrender

I got this datatable:
var table1 = $('#epub_table').dataTable({
"processing": true,
"serverSide": true,
"ajax": {
"type": "POST",
"url": "<?php echo base_url('school_admin/epub_json'); ?>"
},
"columns": [
{"data": "title"},
{"data": "edition"},
{"data": "grade_level"},
{"data": "epub_id",
"mRender": function (data, type, row) {
//var temp1 = row.epub_id;
//var temp2 = row.school_id;
return function testme();
}
},
],
"lengthMenu": [[10, 25, 50, 75, 100, -1], [10, 25, 50, 75, 100, "All"]],
"order": [[0, "desc"]],
});
and I want to call the function:
function testme(){
var temp1 = 16;
var temp2 = 668;
$.ajax(
{ url: location.origin + "/portal/school_admin/get_book_dlcount/" + temp1 + "/" + temp2,
success: function(result){
return result;
}
}
);
}
inside the mrender of the datatable. How do I do this? or is there a better way for me to get data from a controller in codeigniter? thanks
This discussion has been closed.
Answers
Its not recommended to use ajax calls with
columns.render
as this could slow down the table display. Is it possible to get the information needed in the mainajax
request as part of each row?Kevin
well as you could see im calling a function from my controller (url: location.origin + "/portal/school_admin/get_book_dlcount/" + temp1 + "/" + temp2) and i need the data that it returns on the last column of the table. to be exact i need the count of arrays that it will return from the controller.
Inside the controller:
public function get_book_dlcount() {
$dlcount = $this->Admin_model->_ebooks_withaccess($this->uri->segment(3), $this->uri->segment(4));
return $dlcount;
}
And inside the model:
}
or better if there's a way for me in the column.render which I can call a controller directly and have it return its data as the column.render value. This is for CODEIGNITER.