How do I do server side processing within Zend Framework?
How do I do server side processing within Zend Framework?
I need to get my data server side, but I'm having some difficulties.
I am initializing my table like so:
$('#datatable').DataTable({"processing": true,"serverSide": true, ajax: { url: 'batterytest/getdata',type: 'POST'} });
My first attempt involved using the Zend db methods to get the data and return some json from the getdata function, which worked, but then the sorting, pagination, search, etc features of datatables doesn't work. I just get a table with all my data dumped out. I set the POST method thinking that I would need to get info from the datatables object to sort, etc., but I'm not sure how to do that, or if that's even the best way to do this.
So next I looked at the example in the documentation here (https://www.datatables.net/examples/data_sources/server_side.html) and followed the server side script example but I keep getting "invalid json response". I put the included file, ssp.class.php in my public directory. However, I'd rather use the Zend Framework database methods if I can.
Can anyone send me in the right direction with this?
Answers
Yay, I've got it working. That usually happens shortly after I give up and ask for help. :) I ended up using the server_processing.php file and put it in my getdataAction in my controller. After than I just needed to remove the
ajax: { url: 'batterytest/getdata', type: 'POST'
from my table initialization and replaced it with
"ajax":'batterytest/getdata'
I do still wonder though if there is a better way to do this with Zend framework so I can use some of the built in database stuff, but glad to have it working.