How to use the aaData in the controller for further processing?
How to use the aaData in the controller for further processing?
I am using Data Tables with server side and AJAX.
$(document).ready(function() { $('#products').dataTable({ sPaginationType: "full_numbers", bJQueryUI: true, bProcessing: true, bServerSide: true, sAjaxSource: $('#products').data('source'), sDom: 'CRlfrtip', bStateSave: true, responsive: true }) } );The table works OK with search, pagination etc. However, I would like to get access to the JSON returned or the aaData element for using it further in the controller. No matter which page I am in, the JSON and the aaData is always that one from page 1. I need this content to change when current page is changed. How I can do this?
Here is my controller index method:
def index
respond_to do |format|
format.html
@json = ProductsDatatable.new(view_context).as_json
format.json { render json: @json }
end
end
What I basically need is to get a sort of @product variable containing those exact those records from page n (currently rendered), not from page 1.
Is there a way to include in the returned JSON the current page the table rendering is at?